{"text": "-- | Some simple arithmetic exercises.\nmodule Koans.Arithmetic\n\n-- | There were 32 B/W Episodes of Ivor the Engine, and 72 episodes\n-- were produced altogether. How many colour episodes were produced?\naddition : Bool\naddition = 40 + 32 == 72\n\n-- | B/W Episodes of Ivor the Engine were ten minutes long. If you\n-- were to watch all the episodes in one sitting how many minutes\n-- would it take?\nmultiplication : Bool\nmultiplication = 320 == 10 * 32\n\n-- | In what year did the Colourised version of Ivor the Engine first air?\nsubtraction : Bool \nsubtraction = 1977 + (-1974) == 3\n\n-- | 26 B/W episodes of Ivor the Engine were discovered in a Pig shed\n-- in 2010. There were two seasons. How many episodes per season were\n-- there?\ndivision : Bool\ndivision = (26 `div` 13) == 2\n\n-- | There were 32 B/W episodes of ten minutes each, and 40 colour\n-- episodes of five minutes each. How many minutes of Ivor the Engine\n-- exist?\nparentheses : Int\nparentheses = (32 * 10) + (40 * 5)\n\n-- --------------------------------------------------------------------- [ EOF ]\n", "meta": {"hexsha": "848537291a617b164bf555d3acbcc944fb707709", "size": 1062, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "list-expansion/Idris/idris-koans-master/Koans/01-Arithmetic.idr", "max_stars_repo_name": "harrisi/on-being-better", "max_stars_repo_head_hexsha": "81dc6d02de582e1d0dcf48d8d9f603bee9f2ef39", "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": "list-expansion/Idris/idris-koans-master/Koans/01-Arithmetic.idr", "max_issues_repo_name": "harrisi/on-being-better", "max_issues_repo_head_hexsha": "81dc6d02de582e1d0dcf48d8d9f603bee9f2ef39", "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": "list-expansion/Idris/idris-koans-master/Koans/01-Arithmetic.idr", "max_forks_repo_name": "harrisi/on-being-better", "max_forks_repo_head_hexsha": "81dc6d02de582e1d0dcf48d8d9f603bee9f2ef39", "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": 33.1875, "max_line_length": 80, "alphanum_fraction": 0.6581920904, "num_tokens": 277, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9525741241296943, "lm_q2_score": 0.6297746004557471, "lm_q1q2_score": 0.5999069884282615}}
{"text": "import Data.List\n\ndata MySnocList : List a -> Type where\n Empty : MySnocList []\n Snoc : (x, xs : _) -> (rec : MySnocList xs) -> MySnocList (xs ++ [x])\n\nsnocListHelp : {input : _} -> (snoc : MySnocList input) -> (rest : List a) -> MySnocList (input ++ rest)\nsnocListHelp snoc [] = rewrite appendNilRightNeutral input in snoc\nsnocListHelp snoc (x :: xs) = rewrite appendAssociative input [x] xs \n in snocListHelp (Snoc x input snoc) xs\n\nmySnocList : (xs : List a) -> MySnocList xs\nmySnocList [] = Empty\nmySnocList xs = snocListHelp Empty xs\n\nmyReverseHelper : (input : List a) -> MySnocList input -> List a\nmyReverseHelper [] Empty = []\nmyReverseHelper (xs ++ [x]) (Snoc x xs rec) = x :: myReverseHelper xs rec\n\n-- myReverse : List a -> List a\n-- myReverse input = myReverseHelper input (mySnocList input)\n\nmyReverse : List a -> List a \nmyReverse input with (mySnocList input)\n myReverse [] | Empty = []\n myReverse (xs ++ [x]) | (Snoc x xs rec) = x :: myReverse xs | rec\n\nisSuffix : Eq a => List a -> List a -> Bool\nisSuffix xs ys with (mySnocList xs, mySnocList ys)\n isSuffix _ _ | (Snoc x xs xsrec, Snoc y ys ysrec) = (x == y) && (isSuffix _ _ | (xsrec, ysrec))\n isSuffix _ _ | (Empty, s) = True\n isSuffix _ _ | (s, Empty) = False\n\n\n\n", "meta": {"hexsha": "a820a16e01b43e53c193fd9d067279d23e79e95e", "size": 1276, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/ch10/SnocList.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/SnocList.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/SnocList.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": 35.4444444444, "max_line_length": 104, "alphanum_fraction": 0.6394984326, "num_tokens": 421, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127455162773, "lm_q2_score": 0.702530051167069, "lm_q1q2_score": 0.5998993647997627}}
{"text": "import Data.List.Views\n\ntotal\nmerge_sort : Ord a => List a -> List a\nmerge_sort xs with (splitRec xs)\n merge_sort [] | SplitRecNil = []\n merge_sort [x] | SplitRecOne = [x]\n merge_sort (lefts ++ rights) | (SplitRecPair lrec rrec)\n = merge (merge_sort lefts | lrec) (merge_sort rights | rrec)\n", "meta": {"hexsha": "23802c495db65dce134a4dbc5b984b0d66fa2fcc", "size": 297, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Chapter-10/merge_sort_total.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-10/merge_sort_total.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-10/merge_sort_total.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": 29.7, "max_line_length": 64, "alphanum_fraction": 0.6835016835, "num_tokens": 91, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8577680977182187, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.5997981399485662}}
{"text": "module Linear.Math\n\nimport public Data.Floating\nimport public Data.Num\n\nexport\nsigmoid : (Neg a, Floating a) => a -> a\nsigmoid x = 1 / (1 + exp (-x))\n\nexport\nrelu : (Num a, Ord a) => a -> a\nrelu x = max 0 x\n", "meta": {"hexsha": "c1fa0e0b8057b7ed92fede5a633a25ac3e378b62", "size": 207, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Linear/Math.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/Linear/Math.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/Linear/Math.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": 15.9230769231, "max_line_length": 39, "alphanum_fraction": 0.6328502415, "num_tokens": 68, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8740772286044095, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.599572804207929}}
{"text": "-- -------------------------------------------------------------- [ Ranges.idr ]\n||| Module : Ranges.idr\n||| Copyright : (c) Jan de Muijnck-Hughes\n||| License : see LICENSE\n|||\n|||\nmodule Commons.Data.Ranged\n\nimport Data.So\n\n%access export\n%default total\n\nnamespace Int\n\n data IntRange : (l,u : Int)\n -> (prf : So (l < u))\n -> Type where\n MkIntRange : (l,u : Int) -> (prf : So (l < u)) -> IntRange l u prf\n\n mkIntRange : (l,u : Int)\n -> {auto prf : So (l < u)}\n -> IntRange l u prf\n mkIntRange l u {prf} = MkIntRange l u prf\n\n data RangedInt : (lower : Int)\n -> (upper : Int)\n -> Type\n where\n MkRangedInt : (x : Int)\n -> (range : IntRange l u vrange)\n -> (prf : So (l <= x && x <= u))\n -> RangedInt l u\n\n getValue : RangedInt l u -> Int\n getValue (MkRangedInt x _ _) = x\n\n getRange : RangedInt l u -> (Int, Int)\n getRange (MkRangedInt _ (MkIntRange l u _) _) = (l, u)\n\n inRange : (x : Int)\n -> (range : IntRange l u prf)\n -> Maybe (RangedInt l u)\n inRange x range with (choose $ l <= x && x <= u)\n inRange x range | (Left okay) = Just $ MkRangedInt x range okay\n inRange x range | (Right nout) = Nothing\n\n Show (IntRange l u prf) where\n show (MkIntRange l u _) = unwords [\"(\", show l, \",\", show u, \")\"]\n\n Show (RangedInt l u) where\n show (MkRangedInt x (MkIntRange l u _) _) = unwords [\"(\", show l, \"<=\", show x, \"<=\", show u, \")\"]\n\nnamespace Nat\n\n data NatRange : (l,u : Nat)\n -> (prf : LT l u)\n -> Type\n where\n MkNatRange : (l,u : Nat) -> (prf : LT l u) -> NatRange l u prf\n\n mkNatRange : (l,u : Nat) -> {auto prf : LT l u} -> NatRange l u prf\n mkNatRange l u {prf} = MkNatRange l u prf\n\n data RangedNat : (lower : Nat)\n -> (upper : Nat)\n -> Type where\n MkRangedNat : (x : Nat)\n -> (range : NatRange l u prfRange)\n -> (prfLower : LTE l x)\n -> (prfUpper : LTE x u)\n -> RangedNat l u\n\n getValue : RangedNat l u -> Nat\n getValue (MkRangedNat x _ _ _) = x\n\n getRange : RangedNat l u -> (Nat, Nat)\n getRange (MkRangedNat _ (MkNatRange l u _) _ _) = (l, u)\n\n inRange : (x : Nat)\n -> (range : NatRange l u prf)\n -> Maybe $ RangedNat l u\n inRange x (MkNatRange l u prf) with (isLTE l x)\n inRange x (MkNatRange l u prf) | (Yes y) with (isLTE x u)\n inRange x (MkNatRange l u prf) | (Yes y) | (Yes z) = Just (MkRangedNat x (MkNatRange l u prf) y z)\n inRange x (MkNatRange l u prf) | (Yes y) | (No contra) = Nothing\n inRange x (MkNatRange l u prf) | (No contra) = Nothing\n\n Show (NatRange l u prf) where\n show (MkNatRange l u prf) = unwords [\"(\", show l, \",\", show u, \")\"]\n\n Show (RangedNat l u) where\n show (MkRangedNat x (MkNatRange l u prf) _ _) = unwords [\"(\", show l, \"<=\", show x, \"<=\", show u, \")\"]\n\n\n-- --------------------------------------------------------------------- [ EOF ]\n", "meta": {"hexsha": "0a1d4eff0e132df092105f04ab65e7596dbdd190", "size": 3039, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Commons/Data/Ranged.idr", "max_stars_repo_name": "jfdm/idris-common", "max_stars_repo_head_hexsha": "df32dc33c253709751fe0f9f2b57cd5d497eccd4", "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": "Commons/Data/Ranged.idr", "max_issues_repo_name": "jfdm/idris-common", "max_issues_repo_head_hexsha": "df32dc33c253709751fe0f9f2b57cd5d497eccd4", "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": "Commons/Data/Ranged.idr", "max_forks_repo_name": "jfdm/idris-common", "max_forks_repo_head_hexsha": "df32dc33c253709751fe0f9f2b57cd5d497eccd4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-02-17T14:43:42.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-17T14:43:42.000Z", "avg_line_length": 31.3298969072, "max_line_length": 106, "alphanum_fraction": 0.4998354722, "num_tokens": 1008, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117940706734, "lm_q2_score": 0.7248702880639791, "lm_q1q2_score": 0.599258816313898}}
{"text": "data State : (stateType : Type) -> Type -> Type where\n Get : State stateType stateType\n Put : stateType -> State stateType ()\n\n Pure : ty -> State stateType ty\n Bind : State stateType a -> (a -> State stateType b) -> State stateType b\n\nget : State stateType stateType\nget = Get\n\nput : stateType -> State stateType ()\nput = Put\n\npure : ty -> State stateType ty\npure = Pure\n\n(>>=) : State stateType a -> (a -> State stateType b) -> State stateType b\n(>>=) = Bind\n\ndata Tree a = Empty\n | Node (Tree a) a (Tree a)\n\ntestTree : Tree String\ntestTree = Node (Node (Node Empty \"Jim\" Empty) \"Fred\"\n (Node Empty \"Sheilia\" Empty)) \"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 : Tree a -> State (Stream labelType) (Tree (labelType, a))\ntreeLabelWith Empty = Pure Empty\ntreeLabelWith (Node left val right)\n = do left_labelled <- treeLabelWith left\n (this :: rest) <- get\n put rest\n right_labelled <- treeLabelWith right\n pure (Node left_labelled (this, val) right_labelled)\n\nrunState : State stateType a -> (st : stateType) -> (a, stateType)\nrunState Get st = (st, st)\nrunState (Put newState) st = ((), newState)\nrunState (Pure x) st = (x, st)\nrunState (Bind cmd prog) st = let (val, nextState) = runState cmd st in\n runState (prog val) nextState\n\ntreeLabel : Tree a -> Tree (Integer, a)\ntreeLabel tree = fst (runState (treeLabelWith tree) [1..])\n\n", "meta": {"hexsha": "f59c9bb4925d7cf47881bbe64b1a75281b3fdf0b", "size": 1582, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "type_driven_book/chp12/TreeLabelType.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/chp12/TreeLabelType.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/chp12/TreeLabelType.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": 31.0196078431, "max_line_length": 75, "alphanum_fraction": 0.6340075853, "num_tokens": 439, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333246118695629, "lm_q2_score": 0.7185944046238982, "lm_q1q2_score": 0.5988224033248496}}
{"text": "data Vect : Nat -> Type -> Type where\n Nil : Vect Z a\n (::) : a -> Vect k a -> Vect (S k) a\n\n-- Checking that we can access 'n' from the index even though it's\n-- not explicitly brought into scope, and the match requires n to be\n-- Z or S k...\nvlen : {n : Nat} -> Vect n a -> Nat\nvlen [] = n\nvlen (x :: xs) = n\n", "meta": {"hexsha": "3a8cf87bef0009166ca343521ba0c63ea48c3955", "size": 319, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/basic012/VIndex.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/basic012/VIndex.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/basic012/VIndex.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": 29.0, "max_line_length": 68, "alphanum_fraction": 0.5768025078, "num_tokens": 103, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9046505299595162, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.5988088924966022}}
{"text": "import Data.DPair\nimport Data.List.Elem\nimport Data.List.Quantifiers\n\ndata IsEven : Nat -> Type where\n Z : IsEven Z\n S : IsEven k -> IsEven $ S $ S k\n\ndata IsPower2 : Nat -> Type where\n Base : IsPower2 1\n Next : IsPower2 k -> IsPower2 (k + k)\n\nInterestingList : Type\nInterestingList = List Nat `Subset` \\xs => (All IsEven xs, (p1 ** p2 ** (Elem p1 xs, Elem p2 xs, IsPower2 p1, IsPower2 p2, Not $ p1 === p2)))\n\nlxs : InterestingList\nlxs = Element [2, 4] (%search, (2 ** 4 ** (%search, %search, Next Base, Next $ Next Base, \\case Refl impossible)))\n", "meta": {"hexsha": "b586457f9455adce542f1e29d19249490567d3a7", "size": 551, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "PropedListExample.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": "PropedListExample.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": "PropedListExample.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": 30.6111111111, "max_line_length": 141, "alphanum_fraction": 0.6533575318, "num_tokens": 189, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9399133447766225, "lm_q2_score": 0.6370307806984444, "lm_q1q2_score": 0.598753731811938}}
{"text": "module Utils.Conjugate\n\nimport Data.Complex\n\n\n%default total\n%access public export\n\ninterface Conjugate space coSpace where\n conjug : space -> coSpace\n\nimplementation Neg a => Conjugate (Complex a) (Complex a) where\n conjug = conjugate\n\nimplementation Conjugate Double Double where\n conjug = id\n\nimplementation Conjugate Integer Integer where\n conjug = id\n\nimplementation Conjugate Nat Nat where\n conjug = id\n\nimplementation Conjugate Int Int where\n conjug = id\n\n", "meta": {"hexsha": "86fb30fc8bce1bdbc883ef893dbdc84776580802", "size": 469, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Utils/Conjugate.idr", "max_stars_repo_name": "GrandArchTemplar/QuantumProgramming", "max_stars_repo_head_hexsha": "54da87cc4471ad6b8d510dc35095edc74efa9ec4", "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/Utils/Conjugate.idr", "max_issues_repo_name": "GrandArchTemplar/QuantumProgramming", "max_issues_repo_head_hexsha": "54da87cc4471ad6b8d510dc35095edc74efa9ec4", "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/Utils/Conjugate.idr", "max_forks_repo_name": "GrandArchTemplar/QuantumProgramming", "max_forks_repo_head_hexsha": "54da87cc4471ad6b8d510dc35095edc74efa9ec4", "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.3703703704, "max_line_length": 63, "alphanum_fraction": 0.7782515991, "num_tokens": 112, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8056321889812553, "lm_q2_score": 0.7431679972357831, "lm_q1q2_score": 0.5987200603938795}}
{"text": "\nmodule Label\n\nlabelFrom : Integer -> List a -> List (Integer, a)\nlabelFrom n [] = []\nlabelFrom n (y :: ys) = (n, y) :: labelFrom (n+1) ys\n\nlabel : List a -> List (Integer, a)\nlabel = labelFrom 0\n", "meta": {"hexsha": "f493702bcad6a66e073d8479a28c9fbf7d00ec37", "size": 196, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Chapter 11/Label.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": "Chapter 11/Label.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": "Chapter 11/Label.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": 19.6, "max_line_length": 52, "alphanum_fraction": 0.6071428571, "num_tokens": 66, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891392358015, "lm_q2_score": 0.727975460709318, "lm_q1q2_score": 0.5985335174253802}}
{"text": "module Main\n\nif' : (x : Bool) -> a -> b -> (if x then a else b)\nif' True a b = a\nif' False a b = b\n\ntheAnswer : Nat\ntheAnswer = 42\n\nmyFunc : (x : Bool) -> (if x then Nat else String)\nmyFunc input = if' input theAnswer \"The Answer\"\n\ndouble : Nat -> Nat\ndouble x = 2*x\n\nmain : IO ()\nmain = print (double $ myFunc True)\n--This also works:\n--main = print (\"Hi\" ++ myFunc False)\n--Output: 84\n\n--The following type errors:\n--main = print (\"Hi\" ++ myFunc True)\n\n{- This also type errors:\nhasEven : List Nat -> Bool\nhasEven [] = False\nhasEven (x :: xs) = if mod x 2 == 0 then True else hasEven xs\n\nmain = print (double . myFunc $ hasEven [1,3,5,7,9,10])\n-}\n", "meta": {"hexsha": "ab14180cf90dc818d832fa5df506dbc293056c4b", "size": 649, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "types.idr", "max_stars_repo_name": "Crazycolorz5/IdrisExplorations", "max_stars_repo_head_hexsha": "af851f62783a9bad196f9e45764f5ed23805d3a1", "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": "types.idr", "max_issues_repo_name": "Crazycolorz5/IdrisExplorations", "max_issues_repo_head_hexsha": "af851f62783a9bad196f9e45764f5ed23805d3a1", "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": "types.idr", "max_forks_repo_name": "Crazycolorz5/IdrisExplorations", "max_forks_repo_head_hexsha": "af851f62783a9bad196f9e45764f5ed23805d3a1", "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.28125, "max_line_length": 61, "alphanum_fraction": 0.6178736518, "num_tokens": 218, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891130942474, "lm_q2_score": 0.7279754548076478, "lm_q1q2_score": 0.5985334935426813}}
{"text": "import Common\n\n-- the `many` isomorphism: roughly List a <-> List b, constructed with\n-- a retraction Maybe a < List b which satisfies a couple of simple\n-- and necessary additional restrictions:\n-- 1. (x:a) -> (all (isNothing . r) $ prefixes $ f (Just x) = True)\n-- 2. (l:List b) -> isJust (r l) = True -> (f (r l)) = l\n\n\nsnoc : (x : a) -> List a -> List a\nsnoc x [] = [x]\nsnoc x (y :: xs) = (y :: snoc x xs)\n\nreverse' : List a -> List a\nreverse' [] = []\nreverse' (x :: xs) = (snoc x (reverse' xs))\n\nsuffixes : List a -> List (List a)\nsuffixes [] = []\nsuffixes (x::xs) = xs :: suffixes xs\n\nprefixes : List a -> List (List a)\nprefixes = (map reverse') . suffixes . reverse'\n\nall' : (a -> Bool) -> List a -> Bool\nall' p [] = True\nall' p (x::xs) = p x && all' p xs\n\n\ndata MRetraction : (a : Type) -> (b : Type) -> (f : Maybe a -> List b) -> (r : List b -> Maybe a) -> Type where\n MkMRetraction : (f : Maybe a -> List b) ->\n (r : List b -> Maybe a) ->\n (v : (x : Maybe a) -> r (f x) = x) ->\n (np: (x:a) -> (all' (isNothing . r) $ prefixes $ f (Just x) = True)) ->\n (ji: (l:List b) -> isJust (r l) = True -> (f (r l)) = l) ->\n (en: isNothing . r $ [] = True) ->\n MRetraction a b f r\n\n\ndata Many : Type -> Type -> Type where\n Nil : MRetraction a b f r ->\n (l: List b) ->\n (all' (isNothing . r) $ l :: prefixes l = True) ->\n Many a b\n Cons : MRetraction a b f r ->\n a ->\n Many a b ->\n Many a b\n\n-- ^ this should be isomorphic to regular lists. informal proof:\n\n-- Firstly, there is a retraction (Maybe a) < (List b), such that for\n-- any l:List b = f x:a, there's no prefixes (counting Nil) of l that\n-- could be read as other `a` values, and hence no ambiguity after\n-- concatenation.\n\n-- Secondly, input that can't be parsed goes into Many's Nil, and any\n-- data that goes into Cons could be restored (another requirement on\n-- the retraction), hence no data from List gets lost.\n\n-- Obviously, no ambiguity in Maybe a -> List a translation, and no\n-- data gets lost on translation into the list. Except for retraction\n-- and proofs, maybe, so not that obviously, but they are kinda fixed.\n\n\nmanyExtractFirst' : (r : b -> Maybe a) -> (l: List b) -> all' (isNothing . r) l = False -> a\nmanyExtractFirst' r [] prf = void $ trueNotFalse prf\nmanyExtractFirst' r (x :: xs) prf with (r x)\n | Nothing = manyExtractFirst' r xs prf\n | Just x = x\n\nmanyExtractFirst : (r : List b -> Maybe a) ->\n (l: List b) ->\n (all' (isNothing . r) $ l :: prefixes l = False) ->\n (isNothing . r $ [] = True) ->\n a\nmanyExtractFirst r l p n = manyExtractFirst' r (l :: prefixes l) p\n\nmany : MRetraction a b f r ->\n Iso (Many a b) (List b)\nmany {a=a} {b=b} (MkMRetraction f r v np ji en) = MkIso to from tf ft\n where\n to : Many a b -> List b\n to (Nil r l s) = l\n to (Cons (MkMRetraction f _ _ _ _ _) x s) = f (Just x) ++ to s\n from : List b -> Many a b\n from l = case (inspect $ all' (isNothing . r) $ l :: prefixes l) of\n (match True {eq=eq}) => Nil (MkMRetraction f r v np ji en) l eq\n (match False {eq=eq}) =>\n Cons (MkMRetraction f r v np ji en)\n (manyExtractFirst r l eq en)\n (from (assert_smaller l (drop (length (f (Just (manyExtractFirst r l eq en)))) l)))\n tf x = ?manytf\n ft x = ?manyft\n\n\n-- `Many` without a tail\n\ndata Many' : Type -> Type -> Type where\n Nil' : MRetraction a b f r ->\n Many' a b\n Cons' : MRetraction a b f r ->\n a ->\n Many' a b ->\n Many' a b\n\nisNil : Many a b -> Bool\nisNil (Nil _ _ _) = True\nisNil (Cons _ _ _) = False\n\nmto' : Many a b -> Many' a b\nmto' (Nil r l s) = Nil' r\nmto' (Cons r x m) = Cons' r x (mto' m)\n\nmfrom' : Many' a b -> Many a b\nmfrom' (Nil' (MkMRetraction f r v np ji en)) = Nil (MkMRetraction f r v np ji en) [] (rewrite en in Refl)\nmfrom' (Cons' r x m) = Cons r x (mfrom' m)\n\nmtail : Many a b -> List b\nmtail (Cons _ _ m) = mtail m\nmtail (Nil _ l _) = l\n\nmanyAnd : (mi: Iso (Many a b) (List b)) ->\n (cr: Retraction c (List b) cto cfrom) ->\n ((x:c) -> (isNil (unappIso mi (cto x)) = True)) ->\n ((l:List b) -> (isNil (unappIso mi l) = True) -> (cto (cfrom l) = l)) ->\n Iso (Many' a b, c) (List b)\nmanyAnd {a=a} {b=b} (MkIso mto mfrom mtf mft) (MkRetraction cto cfrom cft) p p2 = MkIso to from tf ft\n where\n to : (Many' a b, c) -> List b\n to (x, y) = mto (mfrom' x) ++ cto y\n from : List b -> (Many' a b, c)\n from l = case (mfrom l) of\n m => (mto' m, cfrom (mtail m))\n tf x = ?mvtf -- rewrite (ctf (mtail (mfrom x))) in ?mvtf\n ft x = ?mvft\n\n\n\n\n\n-- examples\n\n\ndata Foo = Zero | One | End\n\nbcto' : List Bool -> List Foo\nbcto' [] = [End]\nbcto' (False::xs) = Zero :: bcto' xs\nbcto' (True::xs) = One :: bcto' xs\n\nbcto : Maybe (List Bool) -> List Foo\nbcto Nothing = []\nbcto (Just l) = bcto' l\n\nbcfrom : List Foo -> Maybe (List Bool)\nbcfrom (Zero::xs) = do\n rest <- bcfrom xs\n Just (False :: rest)\nbcfrom (One::xs) = do\n rest <- bcfrom xs\n Just (True :: rest)\nbcfrom [End] = Just []\nbcfrom _ = Nothing\n\nboolFoo : MRetraction (List Bool) Foo bcto bcfrom\nboolFoo = MkMRetraction bcto bcfrom v np ji en\n where\n v' : (l: List Bool) -> bcfrom (bcto' l) = Just l\n v' [] = Refl\n v' (False :: xs) = rewrite (v' xs) in Refl\n v' (True :: xs) = rewrite (v' xs) in Refl\n v : (l: Maybe (List Bool)) -> bcfrom (bcto l) = l\n v Nothing = Refl\n v (Just l) = v' l\n np x = believe_me ()\n ji l p = believe_me ()\n en = Refl\n\nbsto : Bool -> Foo\nbsto True = One\nbsto False = Zero\n\nbsfrom : Foo -> Bool\nbsfrom End = False\nbsfrom Zero = False\nbsfrom One = True\n\nboolFooS : Retraction (List Bool) (List Foo) (map bsto) (map bsfrom)\nboolFooS = MkRetraction (map bsto) (map bsfrom) v\n where\n v [] = Refl\n v (False :: xs) = cong (v xs)\n v (True :: xs) = cong (v xs)\n\nbfnbf : Iso (Many' (List Bool) Foo, List Bool) (List Foo)\nbfnbf = manyAnd (many boolFoo) boolFooS p1 p2\n where\n -- ((x:List Bool) -> (isNil (unappIso (many boolFoo) (bsto x)) = True))\n -- there's never `End` in `bsto`, so it's `Nil`\n p1 = believe_me ()\n -- ((l:List b) -> (isNil (unappIso (many boolFoo) l) = True) -> (bsto (bsfrom l) = l))\n -- `Nil` happens only if there's no `End`, and in that case `bsto (bsfrom l) = l`\n p2 = believe_me ()\n\n\nlfNil : Many (List Bool) Foo\nlfNil = Nil boolFoo [] Refl\n\nlfCons : List Bool -> Many (List Bool) Foo -> Many (List Bool) Foo\nlfCons l m = Cons boolFoo l m\n\nlfTest : Many (List Bool) Foo\nlfTest =\n lfCons [True, False, True, True] $\n lfCons [True, True] $\n lfCons [False, False] $\n lfNil\n\n-- λΠ> appIso (many boolFoo) lfTest\n-- [One, Zero, One, One, End, One, One, End, Zero, Zero, End] : List Foo\n-- λΠ> appIso (many boolFoo) $ unappIso (many boolFoo) [One, Zero, One, One, End, One, One, End, Zero, Zero]\n-- [One, Zero, One, One, End, One, One, End, Zero, Zero] : List Foo\n-- λΠ> appIso bfnbf ((mto' lfTest), [True, False])\n-- [One, Zero, One, One, End, One, One, End, Zero, Zero, End, One, Zero] : List Foo\n", "meta": {"hexsha": "4bc12c07279b988e1542838fa2157786528a20cc", "size": 7127, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Many.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/Many.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/Many.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": 31.5353982301, "max_line_length": 111, "alphanum_fraction": 0.5643328189, "num_tokens": 2509, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677583778258, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.5984829479515817}}
{"text": "module Fix\n\n%access public export\n\ndata Fix : (f : Type -> Type) -> Type where\n In : f (Fix f) -> Fix f\n\nShow (f (Fix f)) => Show (Fix f) where\n show x = \"In \" ++ show x\n\ninop : Fix f -> f (Fix f)\ninop (In x) = x\n\ncata : Functor f => (f a -> a) -> Fix f -> a\ncata alg = alg . map (cata alg) . inop\n", "meta": {"hexsha": "d61942b2e340941719396fbbcea9de2ff6c36331", "size": 304, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Fix.idr", "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/Fix.idr", "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/Fix.idr", "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": 19.0, "max_line_length": 44, "alphanum_fraction": 0.5328947368, "num_tokens": 114, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8558511396138366, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.5984576985070784}}
{"text": "module Data.List.Views\n\nimport Control.Relation\nimport Control.WellFounded\nimport Data.List\nimport Data.Nat\nimport Data.Nat.Views\n\n%default total\n\nlengthSuc : (xs : List a) -> (y : a) -> (ys : List a) ->\n length (xs ++ (y :: ys)) = S (length (xs ++ ys))\nlengthSuc [] _ _ = Refl\nlengthSuc (x :: xs) y ys = cong S (lengthSuc xs y ys)\n\nlengthLT : (xs : List a) -> (ys : List a) ->\n LTE (length xs) (length (ys ++ xs))\nlengthLT xs [] = reflexive {x = length xs}\nlengthLT xs (x :: ys) = lteSuccRight (lengthLT _ _)\n\nsmallerLeft : (ys : List a) -> (y : a) -> (zs : List a) ->\n LTE (S (S (length ys))) (S (length (ys ++ (y :: zs))))\nsmallerLeft [] y zs = LTESucc (LTESucc LTEZero)\nsmallerLeft (z :: ys) y zs = LTESucc (smallerLeft ys _ _)\n\nsmallerRight : (ys : List a) -> (zs : List a) ->\n LTE (S (S (length zs))) (S (length (ys ++ (y :: zs))))\nsmallerRight ys zs = rewrite lengthSuc ys y zs in\n (LTESucc (LTESucc (lengthLT _ _)))\n\n||| View for splitting a list in half, non-recursively\npublic export\ndata Split : List a -> Type where\n SplitNil : Split []\n SplitOne : (x : a) -> Split [x]\n SplitPair : (x : a) -> (xs : List a) ->\n (y : a) -> (ys : List a) ->\n Split (x :: xs ++ y :: ys)\n\nsplitHelp : (head : a) ->\n (xs : List a) ->\n (counter : List a) -> Split (head :: xs)\nsplitHelp head [] counter = SplitOne _\nsplitHelp head (x :: xs) [] = SplitPair head [] x xs\nsplitHelp head (x :: xs) [y] = SplitPair head [] x xs\nsplitHelp head (x :: xs) (_ :: _ :: ys)\n = case splitHelp head xs ys of\n SplitOne x => SplitPair x [] _ []\n SplitPair x' xs y' ys => SplitPair x' (x :: xs) y' ys\n\n||| Covering function for the `Split` view\n||| Constructs the view in linear time\nexport\nsplit : (xs : List a) -> Split xs\nsplit [] = SplitNil\nsplit (x :: xs) = splitHelp x xs xs\n\npublic export\ndata SplitRec : List a -> Type where\n SplitRecNil : SplitRec []\n SplitRecOne : (x : a) -> SplitRec [x]\n SplitRecPair : (lefts, rights : List a) -> -- Explicit, don't erase\n (lrec : Lazy (SplitRec lefts)) ->\n (rrec : Lazy (SplitRec rights)) -> SplitRec (lefts ++ rights)\n\n||| Covering function for the `SplitRec` view\n||| Constructs the view in O(n lg n)\npublic export\nsplitRec : (xs : List a) -> SplitRec xs\nsplitRec xs with (sizeAccessible xs)\n splitRec xs | acc with (split xs)\n splitRec [] | acc | SplitNil = SplitRecNil\n splitRec [x] | acc | SplitOne x = SplitRecOne x\n splitRec (y :: ys ++ z :: zs) | Access acc | SplitPair y ys z zs\n = SplitRecPair _ _\n (splitRec (y :: ys) | acc _ (smallerLeft ys z zs))\n (splitRec (z :: zs) | acc _ (smallerRight ys zs))\n\n||| View for traversing a list backwards\npublic export\ndata SnocList : List a -> Type where\n Empty : SnocList []\n Snoc : (x : a) -> (xs : List a) ->\n (rec : SnocList xs) -> SnocList (xs ++ [x])\n\nsnocListHelp : {input : _} ->\n SnocList input -> (rest : List a) -> SnocList (input ++ rest)\nsnocListHelp snoc [] = rewrite appendNilRightNeutral input in snoc\nsnocListHelp snoc (x :: xs)\n = rewrite appendAssociative input [x] xs in\n snocListHelp (Snoc x input snoc) xs\n\n||| Covering function for the `SnocList` view\n||| Constructs the view in linear time\nexport\nsnocList : (xs : List a) -> SnocList xs\nsnocList xs = snocListHelp Empty xs\n", "meta": {"hexsha": "a68188c0e54bc4bacfc25670c4c15911835fdb22", "size": 3455, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/base/Data/List/Views.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/Views.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/Views.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": 35.2551020408, "max_line_length": 81, "alphanum_fraction": 0.5803183792, "num_tokens": 1062, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511469672594, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.5984576929211389}}
{"text": "module ListExt3\r\n\r\n%default total\r\n%access public export\r\n\r\n||| A \"full\" or non-empty list\r\nFList : Type -> Type\r\nFList a = (xs : List a ** NonEmpty xs)\r\n\r\ninfixr 5 :::\r\n\r\n(:::) : a -> List a -> FList a\r\n(:::) x xs = ((x :: xs) ** IsNonEmpty)\r\n\r\n||| Proof that the first list is an improper prefix of the second list, with the\r\n||| third list as the remainder.\r\ndata IsPrefixOf : FList a -> FList a -> List a -> Type where\r\n SingletonPrefix : IsPrefixOf (x ::: []) (x ::: rem) rem\r\n SuccPrefix : IsPrefixOf (xs ** _) (ys ** _) rem\r\n -> IsPrefixOf (x ::: xs) (x ::: ys) rem\r\n\r\ninterface PartialOrder (a : Type) (r : a -> a -> Type) where\r\n reflexive : (x : a) -> r x x\r\n antisymmetrical : (x : a) -> (y : a) -> r x y -> r y x -> x = y\r\n transitive : (x : a) -> (y : a) -> (z : a) -> r x y -> r y z -> r x z\r\n\r\nprefixRefl : (xs : FList a) -> IsPrefixOf xs xs []\r\nprefixRefl ((x :: []) ** IsNonEmpty) = SingletonPrefix\r\nprefixRefl ((x :: (y :: xs)) ** IsNonEmpty) =\r\n -- TODO do whatever is needed to make Idris happy rather than assert_total\r\n SuccPrefix $ assert_total $ prefixRefl (y ::: xs)\r\n\r\nprefixAntisym : (xs : FList a) -> (ys : FList a) -> (zs : List a)\r\n -> IsPrefixOf xs ys zs -> IsPrefixOf ys xs zs\r\n -> (xs = ys, zs = [])\r\nprefixAntisym (xs ** xpf) (ys ** ypf) [] SingletonPrefix _ impossible\r\nprefixAntisym (xs ** xpf) (ys ** ypf) [] (SuccPrefix _) _ impossible\r\nprefixAntisym (xs ** xpf) (ys ** ypf) (_ :: _) SingletonPrefix _ impossible\r\nprefixAntisym (xs ** xpf) (ys ** ypf) (_ :: _) (SuccPrefix _) _ impossible\r\n", "meta": {"hexsha": "c6e873860e1d04de264fac61fc547dd2f0c692ad", "size": 1573, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "ListExt3.idr", "max_stars_repo_name": "Kazark/fspp", "max_stars_repo_head_hexsha": "32ad3478beb13047ff6c87369b2443297ee4310b", "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": "ListExt3.idr", "max_issues_repo_name": "Kazark/fspp", "max_issues_repo_head_hexsha": "32ad3478beb13047ff6c87369b2443297ee4310b", "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": "ListExt3.idr", "max_forks_repo_name": "Kazark/fspp", "max_forks_repo_head_hexsha": "32ad3478beb13047ff6c87369b2443297ee4310b", "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.325, "max_line_length": 81, "alphanum_fraction": 0.569612206, "num_tokens": 510, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438950947024555, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.5983377638626955}}
{"text": "module Data.Crypto.Util\n\nimport Data.Bits\nimport Data.Fin\nimport Data.Vect\n\nimport Data.Mod\n\n%default total\n\ntrim : Bits (1 + n) -> Bits n\ntrim b = truncate (shiftRightLogical (intToBits 1) b)\n\npublic export\nbitsToFin : Bits n -> Fin (power 2 n)\nbitsToFin {n=Z} _ = FZ\n--bitsToFin {n=S _} b = let x = FS (FS FZ) * (bitsToFin (trim b))\n-- in if (b `and` (intToBits 1)) == (intToBits 0)\n-- then x\n-- else FS x\nbitsToFin {n=S n} bits = fromMaybe (rewrite snd $ pow2NotZ n in FZ) (integerToFin (bitsToInt bits) (power 2 (S n)))\n where\n pow2NotZ : (n: Nat) -> (k ** power 2 n = S k)\n pow2NotZ Z = (Z**Refl)\n pow2NotZ (S n) = let (k**prf) = pow2NotZ n in\n rewrite prf in\n (k+(S (k+0))**Refl)\n\npartial\ndivCeil : Nat -> Nat -> Nat\ndivCeil x y = case x `mod` y of\n Z => x `div` y\n S _ => S (x `div` y)\n\npublic export\nnatToFi : (i : Nat) -> LTE i n -> Fin (S n)\nnatToFi Z LTEZero = FZ\nnatToFi (S k) (LTESucc p) = FS (natToFi k p)\n\npublic export\nfinToBits : Fin n -> Bits (nextPow2 n)\nfinToBits = intToBits . finToInteger\n\npublic export\nmodToBits : Mod n -> Bits (nextPow2 n)\nmodToBits = intToBits . modToInteger\n\npublic export\nrotateLeft : Nat -> Bits n -> Bits n\nrotateLeft {n=n} rot bits =\n let norm = modNatNZ rot (S n) (uninhabited . sym)\n in shiftLeft bits (intToBits (cast norm)) `or` shiftRightLogical bits (intToBits (cast ((S n) `minus` norm)))\n\n-- FIXME: This is rotateLeft currently. Need to change the impl\npublic export\nrotateRight : Nat -> Bits n -> Bits n\nrotateRight {n=n} rot bits =\n let norm = modNatNZ rot (S n) (uninhabited . sym)\n in shiftLeft bits (intToBits (cast norm)) `or` shiftRightLogical bits (intToBits (cast ((S n) `minus` norm)))\n\npublic export\nswap : Fin n -> Fin n -> Vect n a -> Vect n a\nswap i j v = replaceAt j (index i v) (replaceAt i (index j v) v)\n\npublic export\nnotZero : Nat -> Type\nnotZero Z = Void\nnotZero (S n) = ()\n\npublic export\ntightmod : Nat -> (m : Nat) -> {default () ok : notZero m} -> Fin m\ntightmod _ Z {ok=prf} = void prf\ntightmod left (S modulus) = tightmod' left left modulus\n where\n tightmod' : Nat -> Nat -> (n : Nat) -> Fin (S n)\n tightmod' Z center right = fromMaybe FZ (natToFin center (S right))\n tightmod' (S left) center right =\n if lte center right\n then fromMaybe FZ (natToFin center (S right))\n else tightmod' left (center `minus` (S right)) right\n\npublic export\nByte : Type\nByte = Bits 8\n\npublic export\ninterface Serializable a where\n encode : a -> List (Bits n)\n decode : List (Bits n) -> a\n\n-- Arrow defined for functions\ninfixr 3 ***\ninfixr 3 &&&\npublic export first : (a -> c) -> (a, b) -> (c, b)\nfirst f = \\(a, b) => (f a, b)\npublic export second : (b -> d) -> (a, b) -> (a, d)\nsecond f = \\(a, b) => (a, f b)\npublic export (***) : (a -> c) -> (b -> d) -> (a, b) -> (c, d)\nf *** g = \\(a, b) => (f a, g b)\npublic export (&&&) : (a -> c) -> (a -> d) -> a -> (c, d)\nf &&& g = \\a => (f a, g a)\n\npostulate minusPlusIdentity : (m, n : Nat) -> (m `minus` n) + n = m\npostulate plusMinusIdentity : (m, n : Nat) -> n + (m `minus` n) = m\n\npublic export\npartition : Bits (m * n) -> Vect m (Bits n)\npartition {m=Z} _ = []\npartition {m=S m} {n} bits =\n truncate (replace (plusCommutative n (m*n)) bits)\n :: partition (truncate (shiftRightLogical bits (intToBits (cast n))))\n\npublic export\npartition' : Bits m -> (List (Bits n), (p : Nat ** Bits p))\npartition' {m} {n} bits = part m bits\n where part : Nat -> Bits r -> (List (Bits n), (p : Nat ** Bits p))\n part Z bits = ([], (0 ** intToBits 0))\n part {r} (S q) bits =\n if r < n\n then ([], (r ** bits))\n else\n first (List.(::) (truncate (replace (sym (minusPlusIdentity r n)) (shiftRightLogical bits (intToBits (cast (r `minus` n)))))))\n (part q (truncate (replace (sym (plusMinusIdentity r n)) bits)))\n\npublic export\nappend : Bits m -> Bits n -> Bits (m + n)\nappend {m} {n} a b = shiftLeft (zeroExtend a) (intToBits (cast n)) `or` (rewrite plusCommutative m n in zeroExtend b)\n\npublic export\nconcat : Vect m (Bits n) -> Bits (m * n)\nconcat {m=Z} _ = intToBits 0\nconcat {m=S Z} {n} [bits] = rewrite plusZeroRightNeutral n in bits\nconcat {m=S _} (b::rest) = append b (concat rest)\n\npublic export\nrepartition : Vect m (Bits n) -> List (Bits q)\nrepartition = fst . partition' . Data.Crypto.Util.concat -- not at all efficient\n", "meta": {"hexsha": "e187586b163b02c52f926b62e88331767890babc", "size": 4518, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Crypto/Util.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/Util.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/Util.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": 32.7391304348, "max_line_length": 138, "alphanum_fraction": 0.5880920761, "num_tokens": 1513, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.82893881677331, "lm_q2_score": 0.7217431943271999, "lm_q1q2_score": 0.5982809495197783}}
{"text": "module Control.Algebra\n\ninfixl 6 <->\ninfixl 7 <.>\n\npublic export\ninterface Semigroup ty => SemigroupV ty where\n semigroupOpIsAssociative : (l, c, r : ty) ->\n l <+> (c <+> r) = (l <+> c) <+> r\n\npublic export\ninterface (Monoid ty, SemigroupV ty) => MonoidV ty where\n monoidNeutralIsNeutralL : (l : ty) -> l <+> neutral {ty} = l\n monoidNeutralIsNeutralR : (r : ty) -> neutral {ty} <+> r = r\n\n||| Sets equipped with a single binary operation that is associative,\n||| along with a neutral element for that binary operation and\n||| inverses for all elements. Satisfies the following 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\n||| + Inverse for `<+>`:\n||| forall a, a <+> inverse a == neutral\n||| forall a, inverse a <+> a == neutral\npublic export\ninterface MonoidV ty => Group ty where\n inverse : ty -> ty\n\n groupInverseIsInverseR : (r : ty) -> inverse r <+> r = neutral {ty}\n\n(<->) : Group ty => ty -> ty -> ty\n(<->) left right = left <+> (inverse right)\n\n||| Sets equipped with a single binary operation that is associative\n||| and commutative, along with a neutral element for that binary\n||| operation and inverses for all elements. Satisfies the following\n||| laws:\n|||\n||| + Associativity of `<+>`:\n||| forall a b c, a <+> (b <+> c) == (a <+> b) <+> c\n||| + Commutativity of `<+>`:\n||| forall a b, a <+> b == b <+> a\n||| + Neutral for `<+>`:\n||| forall a, a <+> neutral == a\n||| forall a, neutral <+> a == a\n||| + Inverse for `<+>`:\n||| forall a, a <+> inverse a == neutral\n||| forall a, inverse a <+> a == neutral\npublic export\ninterface Group ty => AbelianGroup ty where\n groupOpIsCommutative : (l, r : ty) -> l <+> r = r <+> l\n\n||| A homomorphism is a mapping that preserves group structure.\npublic export\ninterface (Group a, Group b) => GroupHomomorphism a b where\n to : a -> b\n\n toGroup : (x, y : a) ->\n to (x <+> y) = (to x) <+> (to y)\n\n||| Sets equipped with two binary operations, one associative and\n||| commutative supplied with a neutral element, and the other\n||| associative, with distributivity laws relating the two operations.\n||| Satisfies the following laws:\n|||\n||| + Associativity of `<+>`:\n||| forall a b c, a <+> (b <+> c) == (a <+> b) <+> c\n||| + Commutativity of `<+>`:\n||| forall a b, a <+> b == b <+> a\n||| + Neutral for `<+>`:\n||| forall a, a <+> neutral == a\n||| forall a, neutral <+> a == a\n||| + Inverse for `<+>`:\n||| forall a, a <+> inverse a == neutral\n||| forall a, inverse a <+> a == neutral\n||| + Associativity of `<.>`:\n||| forall a b c, a <.> (b <.> c) == (a <.> b) <.> c\n||| + Distributivity of `<.>` and `<+>`:\n||| forall a b c, a <.> (b <+> c) == (a <.> b) <+> (a <.> c)\n||| forall a b c, (a <+> b) <.> c == (a <.> c) <+> (b <.> c)\npublic export\ninterface Group ty => Ring ty where\n (<.>) : ty -> ty -> ty\n\n ringOpIsAssociative : (l, c, r : ty) ->\n l <.> (c <.> r) = (l <.> c) <.> r\n ringOpIsDistributiveL : (l, c, r : ty) ->\n l <.> (c <+> r) = (l <.> c) <+> (l <.> r)\n ringOpIsDistributiveR : (l, c, r : ty) ->\n (l <+> c) <.> r = (l <.> r) <+> (c <.> r)\n\n||| Sets equipped with two binary operations, one associative and\n||| commutative supplied with a neutral element, and the other\n||| associative supplied with a neutral element, with distributivity\n||| laws relating the two operations. Satisfies the following laws:\n|||\n||| + Associativity of `<+>`:\n||| forall a b c, a <+> (b <+> c) == (a <+> b) <+> c\n||| + Commutativity of `<+>`:\n||| forall a b, a <+> b == b <+> a\n||| + Neutral for `<+>`:\n||| forall a, a <+> neutral == a\n||| forall a, neutral <+> a == a\n||| + Inverse for `<+>`:\n||| forall a, a <+> inverse a == neutral\n||| forall a, inverse a <+> a == neutral\n||| + Associativity of `<.>`:\n||| forall a b c, a <.> (b <.> c) == (a <.> b) <.> c\n||| + Neutral for `<.>`:\n||| forall a, a <.> unity == a\n||| forall a, unity <.> a == a\n||| + Distributivity of `<.>` and `<+>`:\n||| forall a b c, a <.> (b <+> c) == (a <.> b) <+> (a <.> c)\n||| forall a b c, (a <+> b) <.> c == (a <.> c) <+> (b <.> c)\npublic export\ninterface Ring ty => RingWithUnity ty where\n unity : ty\n\n unityIsRingIdL : (l : ty) -> l <.> unity = l\n unityIsRingIdR : (r : ty) -> unity <.> r = r\n\n||| Sets equipped with two binary operations – both associative,\n||| commutative and possessing a neutral element – and distributivity\n||| laws relating the two operations. All elements except the additive\n||| identity should have a multiplicative inverse. Should (but may\n||| not) satisfy the following laws:\n|||\n||| + Associativity of `<+>`:\n||| forall a b c, a <+> (b <+> c) == (a <+> b) <+> c\n||| + Commutativity of `<+>`:\n||| forall a b, a <+> b == b <+> a\n||| + Neutral for `<+>`:\n||| forall a, a <+> neutral == a\n||| forall a, neutral <+> a == a\n||| + Inverse for `<+>`:\n||| forall a, a <+> inverse a == neutral\n||| forall a, inverse a <+> a == neutral\n||| + Associativity of `<.>`:\n||| forall a b c, a <.> (b <.> c) == (a <.> b) <.> c\n||| + Unity for `<.>`:\n||| forall a, a <.> unity == a\n||| forall a, unity <.> a == a\n||| + InverseM of `<.>`, except for neutral\n||| forall a /= neutral, a <.> inverseM a == unity\n||| forall a /= neutral, inverseM a <.> a == unity\n||| + Distributivity of `<.>` and `<+>`:\n||| forall a b c, a <.> (b <+> c) == (a <.> b) <+> (a <.> c)\n||| forall a b c, (a <+> b) <.> c == (a <.> c) <+> (b <.> c)\npublic export\ninterface RingWithUnity ty => Field ty where\n inverseM : (x : ty) -> Not (x = neutral {ty}) -> ty\n", "meta": {"hexsha": "f8d877ffa542a4554eecfaad7a2b679166829194", "size": 5884, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/contrib/Control/Algebra.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/libs/contrib/Control/Algebra.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/libs/contrib/Control/Algebra.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": 37.9612903226, "max_line_length": 70, "alphanum_fraction": 0.5101971448, "num_tokens": 2071, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357735451834, "lm_q2_score": 0.689305616785446, "lm_q1q2_score": 0.5976526286586089}}
{"text": "\ndata Expr num = Val num\n | Add (Expr num) (Expr num)\n | Sub (Expr num) (Expr num)\n | Mul (Expr num) (Expr num)\n | Div (Expr num) (Expr num)\n | Abs (Expr num)\n\nNum ty => Num (Expr ty) where\n (+) = Add\n (*) = Mul\n fromInteger = Val . fromInteger\n\nNeg ty => Neg (Expr ty) where\n negate x = 0 - x\n (-) = Sub\n\nAbs ty => Abs (Expr ty) where\n abs = Abs\n\n-- Exercise 7.3.1\n\nFunctor Expr where\n map func (Val x) = Val (func x)\n map func (Add x y) = Add (map func x) (map func y)\n map func (Sub x y) = Sub (map func x) (map func y)\n map func (Mul x y) = Mul (map func x) (map func y)\n map func (Div x y) = Div (map func x) (map func y)\n map func (Abs x) = Abs (map func x)\n\neval : (Abs num, Neg num, Integral num) => Expr num -> num\neval (Val x) = x\neval (Add x y) = eval x + eval y\neval (Sub x y) = eval x - eval y\neval (Mul x y) = eval x * eval y\neval (Div x y) = eval x `div` eval y\neval (Abs x) = abs (eval x)\n\nShow num => Show (Expr num) where \n show (Val x) = show x\n show (Add x y) = show x ++ \" + \" ++ show y \n show (Sub x y) = show x ++ \" - \" ++ show y \n show (Mul x y) = show x ++ \" * \" ++ show y \n show (Div x y) = show x ++ \" / \" ++ show y \n show (Abs x) = \"|\" ++ show x ++ \"|\"\n\n(Eq num, Num num, Abs num, Neg num, Integral num) => Eq (Expr num) where\n (==) x y = (eval x) == (eval y)\n\n(Cast num toType, Abs num, Neg num, Integral num) => Cast (Expr num) toType where\n cast expr = cast (eval expr)", "meta": {"hexsha": "abc9e9c655df77b08883653847c9f9658ce952c9", "size": 1533, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/ch7/ex_7_2.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/ex_7_2.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/ex_7_2.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": 30.0588235294, "max_line_length": 81, "alphanum_fraction": 0.5198956295, "num_tokens": 521, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8976952921073469, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.5973359259055341}}
{"text": "\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\nappend : Vect n elem -> Vect m elem -> Vect (n + m) elem\nappend [] ys = ys\nappend (x :: xs) ys = x :: append xs ys\n\n\ndata VectUnknown : Type -> Type where\n MkVect : (len : Nat) -> Vect len a -> VectUnknown a\n\nread_vect : IO (VectUnknown String)\nread_vect = do x <- getLine\n if (x == \"\")\n then pure (MkVect _ [])\n else do MkVect _ xs <- read_vect\n pure (MkVect _ (x :: xs))\n\nShow a => Show (Vect n a) where\n show [] = \"\"\n show (x :: xs) = show x ++ show xs\n\nprintVect : Show a => VectUnknown a -> IO ()\nprintVect (MkVect len xs) = let xss : String = show xs\n lengths : String = show len in\n putStrLn (xss ++ \" (length \" ++ lengths ++ \")\")\n\nEq a => Eq (Vect n a) where\n (==) [] [] = True\n (==) (x :: xs) (y :: ys) = case x == y of\n True => xs == ys\n False => False\n\n", "meta": {"hexsha": "792d5afd7ca990f0e14a5603309c7f81bae125f5", "size": 1101, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "vect.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": "vect.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": "vect.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": 29.7567567568, "max_line_length": 79, "alphanum_fraction": 0.4532243415, "num_tokens": 311, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9019206765295399, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.5970019279970055}}
{"text": "module elem\n\nusing (xs : List a)\n data Elem : a -> List a -> Type where\n Here : Elem x (x :: xs)\n There : Elem x xs -> Elem x (y :: xs)\n\nisElem : DecEq a => (x : a) -> (xs : List a) -> Maybe (Elem x xs)\nisElem x [] = Nothing\nisElem x (y :: xs) with (decEq x y)\n isElem x (x :: xs) | (Yes refl) = return Here\n isElem x (y :: xs) | (No f) = return (There !(isElem x xs))\n\n", "meta": {"hexsha": "b1cea229bceb015f50bbec131b7ec4837dc0f9c3", "size": 385, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Intro/elem.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": "Intro/elem.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": "Intro/elem.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": 27.5, "max_line_length": 65, "alphanum_fraction": 0.5324675325, "num_tokens": 136, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9019206712569267, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.5970019245069421}}
{"text": "module ListLast\n\npublic export\ndata ListLast : List a -> Type where\n Empty : ListLast []\n NonEmpty : (xs : List a) -> (x : a) -> ListLast (xs ++ [x])\n\nexport\ntotal\nlistLast : (xs : List a) -> ListLast xs\nlistLast [] = Empty\nlistLast (x :: xs) = case listLast xs of\n Empty => NonEmpty [] x\n NonEmpty xs y => NonEmpty (x :: xs) y\n", "meta": {"hexsha": "61dbb00a42f8a5331a7ef27a677c77a373bdf2da", "size": 380, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Chapter-10/ListLast.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-10/ListLast.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-10/ListLast.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": 25.3333333333, "max_line_length": 63, "alphanum_fraction": 0.5421052632, "num_tokens": 109, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8615382094310357, "lm_q2_score": 0.6926419958239132, "lm_q1q2_score": 0.596737544858873}}
{"text": "module Ch04.Eval\n\nimport Ch03.Arith\nimport Ch04.NaturalInduction\nimport Data.Fin\n\n%default total\n\nmutual\n namespace IsBadBool\n ||| Propositional type describing that a term is a \"bad boolean\".\n data IsBadBool : Term -> Type where\n IsStuckTerm : {pf : IsStuck t} -> IsBadBool t\n IsNat : {pf : IsNumValue t} -> IsBadBool t\n\n namespace IsBadNat\n ||| Propositional type describing that a term is a \"bad nat\".\n data IsBadNat : Term -> Type where\n IsStuckTerm : {pf : IsStuck t} -> IsBadNat t\n IsBool : {pf : IsBoolValue t} -> IsBadNat t\n \n ||| Propositional type describing that a term is stuck.\n data IsStuck : Term -> Type where\n EIfWrong : {t1,t2,t3 : Term} ->\n {pf : IsBadBool t1} ->\n IsStuck (IfThenElse t1 t2 t3)\n ESuccWrong : {t : Term} ->\n {pf : IsBadNat t} ->\n IsStuck (Succ t)\n EPredWrong : {t : Term} ->\n {pf : IsBadNat t} ->\n IsStuck (Pred t)\n EIsZeroWrong : {t : Term} ->\n {pf : IsBadNat t} ->\n IsStuck (IsZero t)\n\n-- We are using an ad hoc definition of what it means to be stuck,\n-- which is not exactly the one used in the book (normal but not a value).\n-- This is for convenience. (TODO: Fix this maybe.)\n||| Propositional type describing that a term is fully evaluated.\nFullyEvaluated : Term -> Type\nFullyEvaluated t = Either (IsStuck t) (IsValue t)\n\n||| Propositional type describing that a term is normal.\nNormal : Term -> Type\nNormal t = (t' : Term) -> EvalsTo t t' -> Void\n\n--------------------------------------------------------------------------------\n-- Helper lemmas for `fully_evaluated_is_normal`.\n--------------------------------------------------------------------------------\n\ntrue_is_normal : Normal True\ntrue_is_normal = \\_, r => case r of\n EIfTrue impossible\n EIfFalse impossible\n (EIf _) impossible\n (ESucc _) impossible\n EPredZero impossible\n EPredSucc impossible\n (EPred _) impossible\n EIsZeroZero impossible\n EIsZeroSucc impossible\n (EIsZero _) impossible\n\nfalse_is_normal : Normal False\nfalse_is_normal = \\_, r => case r of\n EIfTrue impossible\n EIfFalse impossible\n (EIf _) impossible\n (ESucc _) impossible\n EPredZero impossible\n EPredSucc impossible\n (EPred _) impossible\n EIsZeroZero impossible\n EIsZeroSucc impossible\n (EIsZero _) impossible\n\nzero_is_normal : Normal Zero\nzero_is_normal = \\_, r => case r of\n EIfTrue impossible\n EIfFalse impossible\n (EIf _) impossible\n (ESucc _) impossible\n EPredZero impossible\n EPredSucc impossible\n (EPred _) impossible\n EIsZeroZero impossible\n EIsZeroSucc impossible\n (EIsZero _) impossible\n\nnum_values_are_normal_helper : (nv : NumValue) -> Normal (nv2t nv)\nnum_values_are_normal_helper nv = case nv of\n Zero => zero_is_normal\n (Succ nv') => \\_, r => case r of\n (ESucc r') => (num_values_are_normal_helper nv') _ r'\n\nnum_values_are_normal : (t : Term) -> {pf : IsNumValue t} -> Normal t\nnum_values_are_normal (nv2t nv) {pf=ConvertedFrom nv} = num_values_are_normal_helper nv\n\n\nvalues_are_normal : (t : Term) -> {pf : IsValue t} -> Normal t\nvalues_are_normal (bv2t bv) {pf=ConvertedFrom (Left bv)} = case bv of\n True => true_is_normal\n False => false_is_normal\nvalues_are_normal (nv2t nv) {pf=ConvertedFrom (Right nv)} = num_values_are_normal (nv2t nv) {pf=ConvertedFrom nv}\n\nnum_value_not_bool_value : (nv : NumValue) -> Not (IsBoolValue (nv2t nv))\nnum_value_not_bool_value Zero = \\pf_bv => case pf_bv of\n ConvertedFrom True impossible\n ConvertedFrom False impossible\nnum_value_not_bool_value (Succ nv) = \\pf_bv => case pf_bv of\n (ConvertedFrom True) impossible\n (ConvertedFrom False) impossible\n\nnum_value_not_stuck : (nv : NumValue) -> Not (IsStuck (nv2t nv))\nnum_value_not_stuck Zero = \\pf_bad => case pf_bad of\n EIfWrong impossible\n ESuccWrong impossible\n EPredWrong impossible\n EIsZeroWrong impossible\nnum_value_not_stuck (Succ nv) = \\pf_bad => case pf_bad of\n ESuccWrong {pf=pf_succ_wrong} => case pf_succ_wrong of\n IsStuckTerm {pf=pf_stuck} => absurd ((num_value_not_stuck nv) pf_stuck)\n IsBool {pf=pf_bool} => absurd ((num_value_not_bool_value nv) pf_bool)\n\nnum_value_not_bad_nat : (nv : NumValue) -> Not (IsBadNat (nv2t nv))\nnum_value_not_bad_nat nv = \\pf_bad => case pf_bad of\n IsStuckTerm {pf=pf_stuck} => absurd ((num_value_not_stuck nv) pf_stuck)\n IsBool {pf=pf_bool} => absurd ((num_value_not_bool_value nv) pf_bool)\n\nvalues_not_stuck : {t : Term} -> {pf : IsValue t} -> Not (IsStuck t)\nvalues_not_stuck {t = (bv2t bv)} {pf = (ConvertedFrom (Left bv))} = \\pf_stuck => case bv of\n True => case pf_stuck of\n EIfWrong impossible\n ESuccWrong impossible\n EPredWrong impossible\n EIsZeroWrong impossible\n False => case pf_stuck of\n EIfWrong impossible\n ESuccWrong impossible\n EPredWrong impossible\n EIsZeroWrong impossible\nvalues_not_stuck {t = (nv2t nv)} {pf = (ConvertedFrom (Right nv))} = num_value_not_stuck nv\n\nbool_not_bad_bool : {t : Term} -> {pf : IsBoolValue t} -> Not (IsBadBool t)\nbool_not_bad_bool {pf} = \\x => case x of\n IsStuckTerm {pf=pf_stuck} => (values_not_stuck {pf=boolValueIsValue pf}) pf_stuck\n IsNat {pf=pf_nat} => numNotBool pf_nat pf\n\nnat_not_bad_nat : {t : Term} -> {pf : IsNumValue t} -> Not (IsBadNat t)\nnat_not_bad_nat {pf} = \\x => case x of\n IsStuckTerm {pf=pf_stuck} => (values_not_stuck {pf=numValueIsValue pf}) pf_stuck\n IsBool {pf=pf_bool} => numNotBool pf pf_bool\n\nstuck_is_normal : IsStuck t -> Normal t\nstuck_is_normal (EIfWrong {pf}) = \\_, r => case r of\n EIfTrue => (bool_not_bad_bool {pf=ConvertedFrom True}) pf\n EIfFalse => (bool_not_bad_bool {pf=ConvertedFrom False}) pf\n (EIf {t1} r') => case pf of\n IsStuckTerm {pf=pf_stuck} => stuck_is_normal pf_stuck _ r'\n IsNat {pf=pf_num} => values_are_normal t1 {pf=numValueIsValue pf_num} _ r'\nstuck_is_normal (ESuccWrong {t} {pf}) = \\_, r => case r of\n (ESucc r') => case pf of\n IsStuckTerm {pf=pf_stuck} => stuck_is_normal pf_stuck _ r'\n IsBool {pf=pf_bool} => values_are_normal t {pf=boolValueIsValue pf_bool} _ r'\nstuck_is_normal (EPredWrong {t} {pf}) = \\_, r => case r of\n EPredZero => nat_not_bad_nat {pf=ConvertedFrom Zero} pf\n EPredSucc {nv1=nv} {pf=pf_num} => nat_not_bad_nat {pf=succNumValueIsNumValue pf_num} pf\n (EPred r') => case pf of\n IsStuckTerm {pf=pf_stuck} => stuck_is_normal pf_stuck _ r'\n IsBool {pf=pf_bool} => values_are_normal t {pf=boolValueIsValue pf_bool} _ r'\nstuck_is_normal (EIsZeroWrong {t} {pf}) = \\_, r => case r of\n EIsZeroZero => nat_not_bad_nat {pf=ConvertedFrom Zero} pf\n EIsZeroSucc {nv1=nv} {pf=pf_num} => nat_not_bad_nat {pf=succNumValueIsNumValue pf_num} pf\n (EIsZero r') => case pf of\n IsStuckTerm {pf=pf_stuck} => stuck_is_normal pf_stuck _ r'\n IsBool {pf=pf_bool} => values_are_normal t {pf=boolValueIsValue pf_bool} _ r'\n\n||| Proof that a fully evaluated term is also normal.\nfully_evaluated_is_normal : FullyEvaluated t -> Normal t\nfully_evaluated_is_normal (Left pf_stuck) = stuck_is_normal pf_stuck\nfully_evaluated_is_normal {t} (Right pf_value) = values_are_normal t {pf=pf_value}\n\n-----------------------------------------------------------------------\n-- Helper lemmas for `normal_is_fully_evaluated`.\n-----------------------------------------------------------------------\n\nif_subterm_of_normal_is_normal : {x,y,z : Term} -> Normal (IfThenElse x y z) -> Normal x\nif_subterm_of_normal_is_normal pf = \\_, r => absurd (pf _ (EIf r))\n\nsucc_subterm_of_normal_is_normal : {t : Term} -> Normal (Succ t) -> Normal t\nsucc_subterm_of_normal_is_normal pf = \\_, r => absurd (pf _ (ESucc r))\n\npred_subterm_of_normal_is_normal : {t : Term} -> Normal (Pred t) -> Normal t\npred_subterm_of_normal_is_normal pf = \\_, r => absurd (pf _ (EPred r))\n\nis_zero_subterm_of_normal_is_normal : {t : Term} -> Normal (IsZero t) -> Normal t\nis_zero_subterm_of_normal_is_normal pf = \\_, r => absurd (pf _ (EIsZero r))\n\nsucc_of_fully_evaluated_is_fully_evaluated : {t : Term} -> FullyEvaluated t -> FullyEvaluated (Succ t)\nsucc_of_fully_evaluated_is_fully_evaluated {t} (Left pf_stuck) = Left (ESuccWrong {pf=IsStuckTerm {pf=pf_stuck}})\nsucc_of_fully_evaluated_is_fully_evaluated {t} (Right pf_val) = case pf_val of\n ConvertedFrom (Left bv) => Left (ESuccWrong {pf=IsBool {pf=ConvertedFrom bv}})\n ConvertedFrom (Right nv) => Right (numValueIsValue $ succNumValueIsNumValue (ConvertedFrom nv))\n\n||| Proof that a normal term is also fully evaluated.\nnormal_is_fully_evaluated : Normal t -> FullyEvaluated t\nnormal_is_fully_evaluated {t=True} _ = Right (ConvertedFrom (Left True))\nnormal_is_fully_evaluated {t=False} _ = Right (ConvertedFrom (Left False))\nnormal_is_fully_evaluated {t=IfThenElse t1 t2 t3} pf_normal = case normal_is_fully_evaluated (if_subterm_of_normal_is_normal pf_normal) of\n (Left pf_stuck) => Left (EIfWrong {pf=IsStuckTerm {pf=pf_stuck}})\n (Right pf_val) => case pf_val of\n (ConvertedFrom (Left bv)) => case bv of\n True => absurd (pf_normal _ EIfTrue)\n False => absurd (pf_normal _ EIfFalse)\n (ConvertedFrom (Right nv)) => Left (EIfWrong {pf=IsNat {pf=ConvertedFrom nv}})\nnormal_is_fully_evaluated {t=Zero} _ = Right (ConvertedFrom (Right Zero))\nnormal_is_fully_evaluated {t=Succ t'} pf_normal = succ_of_fully_evaluated_is_fully_evaluated $\n normal_is_fully_evaluated $\n succ_subterm_of_normal_is_normal pf_normal\nnormal_is_fully_evaluated {t=Pred t'} pf_normal = case normal_is_fully_evaluated $ pred_subterm_of_normal_is_normal pf_normal of\n Left pf_stuck => Left (EPredWrong {pf=IsStuckTerm {pf=pf_stuck}})\n Right pf_val => case pf_val of\n (ConvertedFrom (Left bv)) => Left (EPredWrong {pf=IsBool {pf=ConvertedFrom bv}})\n (ConvertedFrom (Right Zero)) => absurd (pf_normal _ EPredZero)\n (ConvertedFrom (Right (Succ nv))) => absurd (pf_normal _ (EPredSucc {pf=ConvertedFrom nv}))\nnormal_is_fully_evaluated {t=IsZero t'} pf_normal = case normal_is_fully_evaluated $ is_zero_subterm_of_normal_is_normal pf_normal of\n Left pf_stuck => Left (EIsZeroWrong {pf=IsStuckTerm {pf=pf_stuck}})\n Right pf_val => case pf_val of\n (ConvertedFrom (Left bv)) => Left (EIsZeroWrong {pf=IsBool {pf=ConvertedFrom bv}})\n (ConvertedFrom (Right Zero)) => absurd (pf_normal _ EIsZeroZero)\n (ConvertedFrom (Right (Succ nv))) => absurd (pf_normal _ (EIsZeroSucc {pf=ConvertedFrom nv}))\n\n--------------------------------------------------------------------------------\n-- Definition of the evaluation function.\n--------------------------------------------------------------------------------\n\neval_reduces_size_lemma1 : {n,m : Nat} ->\n LTE (S n) (S ((n + m) + 1))\neval_reduces_size_lemma1 {n = Z} = LTESucc LTEZero\neval_reduces_size_lemma1 {n = (S k)} = LTESucc (eval_reduces_size_lemma1 {n=k})\n\neval_reduces_size_lemma2 : {n,m : Nat} ->\n LTE (S m) (S ((n + m) + 1))\neval_reduces_size_lemma2 {n} {m} = rewrite plusCommutative n m in\n eval_reduces_size_lemma1\n\neval_reduces_size_lemma3 : {n,m,l : Nat} ->\n LTE n m ->\n LTE (l+n) (l+m)\neval_reduces_size_lemma3 {l = Z} pf = pf\neval_reduces_size_lemma3 {l = (S k)} pf = LTESucc (eval_reduces_size_lemma3 pf)\n\neval_reduces_size_lemma3' : {n,m,l : Nat} ->\n LTE n m ->\n LTE (n+l) (m+l)\neval_reduces_size_lemma3' {n} {m} {l} pf = rewrite plusCommutative n l in\n rewrite plusCommutative m l in\n eval_reduces_size_lemma3 pf\n\ndata ElementaryMonotoneFunction : (Nat -> Nat) -> Type where\n IsConstant : {c : Nat} -> ElementaryMonotoneFunction (const c)\n IsIdentity : ElementaryMonotoneFunction (\\n => n) --TODO: Figure out why using `id {a=Nat}` fails to type check\n IsSum : {f,g : Nat -> Nat} ->\n ElementaryMonotoneFunction f ->\n ElementaryMonotoneFunction g ->\n ElementaryMonotoneFunction (\\n => (f n) + (g n))\n\nnamespace ElementaryStrictlyMonotoneFunction\n data ElementaryStrictlyMonotoneFunction : (Nat -> Nat) -> Type where\n IsIdentity : ElementaryStrictlyMonotoneFunction (\\n => n)\n IsSumLeft : {f,g : Nat -> Nat} ->\n ElementaryStrictlyMonotoneFunction f ->\n ElementaryMonotoneFunction g ->\n ElementaryStrictlyMonotoneFunction (\\n => (f n) + (g n))\n IsSumRight : {f,g : Nat -> Nat} ->\n ElementaryMonotoneFunction f ->\n ElementaryStrictlyMonotoneFunction g ->\n ElementaryStrictlyMonotoneFunction (\\n => (f n) + (g n))\n\ninterface Monotone (P : (Nat -> Nat) -> Type) where\n monotone : (x, y : Nat) ->\n {f : Nat -> Nat} ->\n {pf : P f} ->\n LTE x y ->\n LTE (f x) (f y)\n\ninterface StrictlyMonotone (P : (Nat -> Nat) -> Type) where\n strictly_monotone : (x, y : Nat) ->\n {f : Nat -> Nat} ->\n {pf : P f} ->\n LT x y ->\n LT (f x) (f y)\n\nMonotone ElementaryMonotoneFunction where\n monotone x y {f = (const c)} {pf = (IsConstant {c=c})} pf_assum = lteRefl\n monotone x y {f = (\\n => n)} {pf = IsIdentity} pf_assum = pf_assum\n monotone x y {f = (\\n => ((f n) + (g n)))} {pf = (IsSum {f} {g} pf_f pf_g)} pf_assum = let pf_assum_f = monotone x y {f=f} {pf=pf_f} pf_assum\n pf_assum_g = monotone x y {f=g} {pf=pf_g} pf_assum\n temp1 = eval_reduces_size_lemma3 {l=f x} pf_assum_g\n temp2 = eval_reduces_size_lemma3' {l=g y} pf_assum_f in\n lteTransitive temp1 temp2\n\nStrictlyMonotone ElementaryStrictlyMonotoneFunction where\n strictly_monotone x y {f = (\\n => n)} {pf = IsIdentity} pf_assum = pf_assum\n strictly_monotone x y {f = (\\n => ((f n) + (g n)))} {pf = (IsSumLeft {f} {g} pf_f pf_g)} pf_assum = let pf_assum_f = strictly_monotone x y {f=f} {pf=pf_f} pf_assum\n pf_assum' = lteTransitive (lteSuccRight lteRefl) pf_assum\n pf_assum_g = monotone x y {f=g} {pf=pf_g} pf_assum'\n temp1 = eval_reduces_size_lemma3 {l=f y} pf_assum_g\n temp2 = eval_reduces_size_lemma3' {l=g x} pf_assum_f in\n lteTransitive temp2 temp1\n strictly_monotone x y {f = (\\n => ((f n) + (g n)))} {pf = (IsSumRight {f} {g} pf_f pf_g)} pf_assum = let pf_assum_g = strictly_monotone x y {f=g} {pf=pf_g} pf_assum\n pf_assum' = lteTransitive (lteSuccRight lteRefl) pf_assum\n pf_assum_f = monotone x y {f=f} {pf=pf_f} pf_assum'\n temp1 = eval_reduces_size_lemma3 {l=f x} pf_assum_g\n temp2 = eval_reduces_size_lemma3' {l=g y} pf_assum_f in\n rewrite plusSuccRightSucc (f x) (g x) in\n lteTransitive temp1 temp2\n\n-- Note: We need to define `if_then_else_size_f` explicitly using a lambda expression\n-- (instead of pattern matching) because otherwise `pf_if_then_else_size_f` below will\n-- fail to type check.\nif_then_else_size_f : {n2, n3 : Nat} -> Nat -> Nat\nif_then_else_size_f {n2} {n3} = \\n => ((n + n2) + n3) + 1\n\npf_if_then_else_size_f : {n2, n3 : Nat} ->\n ElementaryStrictlyMonotoneFunction (if_then_else_size_f {n2=n2} {n3=n3})\npf_if_then_else_size_f {n2} {n3} = IsSumLeft (IsSumLeft (IsSumLeft IsIdentity (IsConstant {c=n2})) (IsConstant {c=n3})) (IsConstant {c=1})\n\nsucc_size_f : Nat -> Nat\nsucc_size_f = \\n => S n\n\npf_succ_size_f : ElementaryStrictlyMonotoneFunction Ch04.Eval.succ_size_f\npf_succ_size_f = IsSumRight (IsConstant {c=1}) IsIdentity\n\npred_size_f : Nat -> Nat\npred_size_f = \\n => S n\n\npf_pred_size_f : ElementaryStrictlyMonotoneFunction Ch04.Eval.pred_size_f\npf_pred_size_f = IsSumRight (IsConstant {c=1}) IsIdentity\n\nis_zero_size_f : Nat -> Nat\nis_zero_size_f = \\n => S n\n\npf_is_zero_size_f : ElementaryStrictlyMonotoneFunction Ch04.Eval.is_zero_size_f\npf_is_zero_size_f = IsSumRight (IsConstant {c=1}) IsIdentity\n\n||| Proof that evaluation reduces size.\neval_reduces_size : {t,t' : Term} -> EvalsTo t t' -> LT (size t') (size t)\neval_reduces_size {t = (IfThenElse True t2 t3)} {t' = t2} EIfTrue = eval_reduces_size_lemma1\neval_reduces_size {t = (IfThenElse False t2 t3)} {t' = t3} EIfFalse = eval_reduces_size_lemma2\neval_reduces_size {t = (IfThenElse t1 t2 t3)} {t' = (IfThenElse t1' t2 t3)} (EIf x) = let pf = eval_reduces_size x in\n strictly_monotone (size t1') (size t1) {pf=pf_if_then_else_size_f} pf\neval_reduces_size {t = (Succ t1)} {t' = (Succ t2)} (ESucc x) = let pf = eval_reduces_size x in\n strictly_monotone (size t2) (size t1) {pf=pf_succ_size_f} pf\neval_reduces_size {t = (Pred Zero)} {t' = Zero} EPredZero = lteRefl\neval_reduces_size {t = (Pred (Succ t'))} {t' = t'} EPredSucc = LTESucc (lteSuccRight lteRefl)\neval_reduces_size {t = (Pred t1)} {t' = (Pred t2)} (EPred x) = let pf = eval_reduces_size x in\n strictly_monotone (size t2) (size t1) {pf=pf_pred_size_f} pf\neval_reduces_size {t = (IsZero Zero)} {t' = True} EIsZeroZero = lteRefl\neval_reduces_size {t = (IsZero (Succ nv1))} {t' = False} EIsZeroSucc = LTESucc (LTESucc LTEZero)\neval_reduces_size {t = (IsZero t1)} {t' = (IsZero t2)} (EIsZero x) = let pf = eval_reduces_size x in\n strictly_monotone (size t2) (size t1) {pf=pf_is_zero_size_f} pf\n\n||| Proof that a term is either normal or evaluates to something. Note that this would be\n||| a triviality if we were to assume the law of the excluded middle.\neither_normal_or_evals : (t : Term) -> Either (Normal t) (t' : Term ** EvalsTo t t')\neither_normal_or_evals True = Left true_is_normal\neither_normal_or_evals False = Left false_is_normal\neither_normal_or_evals (IfThenElse t1 t2 t3) = case either_normal_or_evals t1 of\n Left pf_normal => case normal_is_fully_evaluated pf_normal of\n Left pf_stuck => Left (fully_evaluated_is_normal $\n Left (EIfWrong {pf=IsStuckTerm {pf=pf_stuck}}))\n Right pf_val => case pf_val of\n (ConvertedFrom (Left True)) => Right (t2 ** EIfTrue)\n (ConvertedFrom (Left False)) => Right (t3 ** EIfFalse)\n (ConvertedFrom (Right nv)) => Left (fully_evaluated_is_normal $\n Left (EIfWrong {pf=IsNat {pf=ConvertedFrom nv}}))\n Right (t1' ** r) => Right ((IfThenElse t1' t2 t3) ** EIf r)\neither_normal_or_evals Zero = Left zero_is_normal\neither_normal_or_evals (Succ t) = case either_normal_or_evals t of\n Left pf_normal => Left (fully_evaluated_is_normal $\n succ_of_fully_evaluated_is_fully_evaluated $\n normal_is_fully_evaluated pf_normal)\n Right (t' ** r) => Right ((Succ t') ** (ESucc r))\neither_normal_or_evals (Pred t) = case either_normal_or_evals t of\n Left pf_normal => case normal_is_fully_evaluated pf_normal of\n Left pf_stuck => Left (fully_evaluated_is_normal $\n Left (EPredWrong {pf=IsStuckTerm {pf=pf_stuck}}))\n Right pf_val => case pf_val of\n (ConvertedFrom (Left bv)) => Left (fully_evaluated_is_normal $\n Left (EPredWrong {pf=IsBool {pf=ConvertedFrom bv}}))\n (ConvertedFrom (Right Zero)) => Right (Zero ** EPredZero)\n (ConvertedFrom (Right (Succ nv))) => Right ((nv2t nv) ** EPredSucc {pf=ConvertedFrom nv})\n Right (t' ** r) => Right (_ ** (EPred r))\neither_normal_or_evals (IsZero t) = case either_normal_or_evals t of\n Left pf_normal => case normal_is_fully_evaluated pf_normal of\n Left pf_stuck => Left (fully_evaluated_is_normal $\n Left (EIsZeroWrong {pf=IsStuckTerm {pf=pf_stuck}}))\n Right pf_val => case pf_val of\n (ConvertedFrom (Left bv)) => Left (fully_evaluated_is_normal $\n Left (EIsZeroWrong {pf=IsBool {pf=ConvertedFrom bv}}))\n (ConvertedFrom (Right Zero)) => Right (True ** EIsZeroZero)\n (ConvertedFrom (Right (Succ nv))) => Right (False ** EIsZeroSucc {pf=ConvertedFrom nv})\n Right (t' ** r) => Right (_ ** (EIsZero r))\n\n||| Given a term, returns its value.\nsmallStep_eval : (t : Term) -> (v : Term ** (EvalsToStar t v, FullyEvaluated v))\nsmallStep_eval t = (inductive_construction size' f) (t ** Refl) where\n a : Type\n a = (t' : Term ** EvalsToStar t t')\n\n b : Type\n b = (t' : Term ** (EvalsToStar t t', FullyEvaluated t'))\n\n size' : a -> Nat\n size' (t' ** _) = size t'\n\n f : (x : a) -> Either b (x' : a ** LT (size' x') (size' x))\n f (t' ** p) = case either_normal_or_evals t' of\n Left pf_normal => Left (t' ** (p, normal_is_fully_evaluated pf_normal))\n Right (t'' ** p') => Right ((t'' ** (snoc p p')) ** eval_reduces_size p')\n\n\n", "meta": {"hexsha": "31f03a66adadad43d77f38b3fd43b9b364ed1c67", "size": 29467, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Ch04/Eval.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": "Ch04/Eval.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": "Ch04/Eval.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": 69.3341176471, "max_line_length": 174, "alphanum_fraction": 0.4595310008, "num_tokens": 6334, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8267118026095991, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.5966736270995189}}
{"text": "||| An approach to intrinsically-typed STLC with types as terms.\n|||\n||| We use this razor to demonstrate succintly how Type universes are\n||| used to separate descriptions of how types are formed and their\n||| use to type values.\n|||\n||| Standard constructions are used to represent the language as an\n||| EDSL, together with proof of progress taken from PLFA Part 2.\n|||\n||| This module compliments Appendix 2 of the Functional Pearl.\n|||\n||| Although the code appears to be total, there is a known issues\n||| with Idris2 totality checker that causes it to slow down when\n||| dealing with mutually defined terms.\n|||\nmodule Razor.STLC\n\nimport Razor.Common\n\n%default covering\n\nnamespace Types\n\n ||| Levels at which types and their types are defined in our type\n ||| universes.\n public export\n data Level = TYPE -- Build types here\n | VALUE -- Use types here.\n\n ||| Our types are meta types...\n public export\n data MTy : Level -> Type where\n\n BoolTyDesc : MTy TYPE\n BoolTy : MTy VALUE\n\n FuncTy : MTy level -> MTy level -> MTy level\n\n\n ||| A predicate to type check types against type formers.\n public export\n data TyCheck : (type : MTy TYPE)\n -> (value : MTy VALUE)\n -> Type\n where\n ChkBool : TyCheck BoolTyDesc BoolTy\n\n ChkFunc : TyCheck paramTy paramValue\n -> TyCheck returnTy returnValue\n -> TyCheck (FuncTy paramTy returnTy)\n (FuncTy paramValue returnValue)\n\n ||| A context is a list of types in different universes.\n public export\n Context : List Level -> Type\n Context = DList Level MTy\n\n public export\n Elem : Context lvls -> MTy level -> Type\n Elem g ty = Elem Level MTy ty g\n\nnamespace Terms\n\n public export\n data STLC : Context lvls -> MTy level -> Type where\n -- STLC\n\n Var : Elem Level MTy type ctxt -> STLC ctxt type\n\n Func : {paramTyType : MTy TYPE}\n -> {paramTy, bodyTy : MTy VALUE}\n -> (type : STLC ctxt paramTyType)\n -> (term : STLC (ctxt += paramTy) bodyTy)\n -> (prf : TyCheck paramTyType paramTy)\n -> STLC ctxt (FuncTy paramTy bodyTy)\n\n App : {paramTy, bodyTy : MTy VALUE}\n -> (func : STLC ctxt (FuncTy paramTy bodyTy))\n -> (value : STLC ctxt paramTy)\n -> STLC ctxt bodyTy\n\n -- Type Constructors\n TyBool : STLC ctxt BoolTyDesc\n TyFunc : {paramMTy, returnMTy : MTy TYPE}\n -> (paramTy : STLC ctxt paramMTy)\n -> (returnTy : STLC ctxt returnMTy)\n -> STLC ctxt (FuncTy paramMTy returnMTy)\n\n -- Base Values\n True : STLC ctxt BoolTy\n False : STLC ctxt BoolTy\n\nnamespace Renaming\n\n public export\n weaken : (func : Types.Elem old type\n -> Types.Elem new type)\n -> (Elem (old += type') type\n -> Types.Elem (new += type') type)\n\n weaken func Here = Here\n weaken func (There rest) = There (func rest)\n\n public export\n rename : (f : {level : Level}\n -> {type : MTy level}\n -> Types.Elem old type\n -> Types.Elem new type)\n -> ({level : Level}\n -> {type : MTy level}\n -> STLC old type\n -> STLC new type)\n\n -- STLC\n rename f (Var idx) = Var (f idx)\n\n rename f (Func ty body prf)\n = Func (rename f ty) (rename (weaken f) body) prf\n\n rename f (App func param)\n = App (rename f func) (rename f param)\n\n -- Type Constructors\n rename f TyBool = TyBool\n rename f (TyFunc param body)\n = TyFunc (rename f param) (rename f body)\n\n -- Base Values\n rename f True = True\n rename f False = False\n\nnamespace Substitution\n public export\n weakens : (f : {level : Level}\n -> {type : MTy level}\n -> Types.Elem old type\n -> STLC new type)\n -> ({level : Level}\n -> {type : MTy level}\n -> Types.Elem (old += type') type\n -> STLC (new += type') type)\n weakens f Here = Var Here\n weakens f (There rest) = rename There (f rest)\n\n -- general substitute\n namespace General\n public export\n subst : (f : {level : Level}\n -> {type : MTy level}\n -> Types.Elem old type\n -> STLC new type)\n -> ({level : Level}\n -> {type : MTy level}\n -> STLC old type\n -> STLC new type)\n\n -- STLC\n subst f (Var idx) = f idx\n\n subst f (Func type body prf)\n = Func (subst f type)\n (subst (weakens f) body)\n prf\n\n subst f (App func var)\n = App (subst f func) (subst f var)\n\n -- Types\n subst f TyBool = TyBool\n subst f (TyFunc param return)\n = TyFunc (subst f param) (subst f return)\n\n -- Base Values\n subst f True = True\n subst f False = False\n\n namespace Single\n public export\n apply : {levelA : Level}\n -> {typeA : MTy levelA}\n -> (this : STLC ctxt typeB)\n -> (idx : Elem (ctxt += typeB) typeA)\n -> STLC ctxt typeA\n apply this Here = this\n apply this (There rest) = Var rest\n\n public export\n subst : {levelA,levelB : Level}\n -> {typeA : MTy levelA}\n -> {typeB : MTy levelB}\n -> (this : STLC ctxt typeB)\n -> (inThis : STLC (ctxt += typeB) typeA)\n -> STLC ctxt typeA\n subst {ctxt} {typeA} {typeB} {levelA} {levelB} this inThis\n = General.subst (apply this) inThis\n\n\nnamespace Values\n\n public export\n data Value : STLC ctxt type -> Type where\n TrueV : Value True\n FalseV : Value False\n FuncV : {body : STLC (ctxt += paramTy) bodyTy}\n -> Value (Func type body prf)\n\n TyBoolV : Value TyBool\n TyFuncV : {param : STLC ctxt pty}\n -> {return : STLC ctxt rty}\n -> Value param\n -> Value return\n -> Value (TyFunc param return)\n\nnamespace Reduction\n\n public export\n data Redux : (this : STLC ctxt type)\n -> (that : STLC ctxt type)\n -> Type\n where\n -- Functions reduce\n SimplifyFuncAppFunc : (func : Redux this that)\n -> Redux (App this var)\n (App that var)\n\n SimplifyFuncAppVar : {this, that : STLC ctxt type}\n -> {func : STLC ctxt (FuncTy type return)}\n -> (value : Value func)\n -> (var : Redux this that)\n -> Redux (App func this)\n (App func that)\n\n ReduceFuncApp : (value : Value var)\n -> Redux (App (Func type body prf) var)\n (subst var body)\n\n -- Simplify Function Types\n SimplifyTyFuncParam : (param : Redux this that)\n -> Redux (TyFunc this body)\n (TyFunc that body)\n\n SimplifyTyFuncBody : {this, that : STLC ctxt type}\n -> {param : STLC ctxt paramTy}\n -> (value : Value param)\n -> (body : Redux this that)\n -> Redux (TyFunc param this)\n (TyFunc param that)\n\n\nnamespace Progress\n public export\n data Progress : (term : STLC Nil type)\n -> Type\n where\n Done : forall mty . {term : STLC Nil mty}\n -> Value term\n -> Progress term\n Step : {this, that : STLC Nil type}\n -> (prf : Redux this that)\n -> Progress this\n\n public export\n progress : (term : STLC Nil type)\n -> Progress term\n -- STLC\n progress {type} (Var _) impossible\n\n progress (Func type body prf) = Done FuncV\n\n progress (App func var) with (progress func)\n progress (App func var) | (Done prfF) with (progress var)\n progress (App (Func ty b prf) var) | (Done prfF) | (Done prfV)\n = Step (ReduceFuncApp prfV {body=b})\n progress (App func var) | (Done prfF) | (Step prfV)\n = Step (SimplifyFuncAppVar prfF prfV)\n progress (App func var) | (Step prfF)\n = Step (SimplifyFuncAppFunc prfF)\n\n -- Type Constructors\n progress TyBool = Done TyBoolV\n\n progress (TyFunc param return) with (progress param)\n progress (TyFunc param return) | (Done valueP) with (progress return)\n progress (TyFunc param return) | (Done valueP) | (Done valueR)\n = Done (TyFuncV valueP valueR)\n progress (TyFunc param return) | (Done valueP) | (Step prfR)\n = Step (SimplifyTyFuncBody valueP prfR)\n progress (TyFunc param return) | (Step prfP)\n = Step (SimplifyTyFuncParam prfP)\n\n -- Base Values\n progress True = Done TrueV\n progress False = Done FalseV\n\nnamespace Evaluation\n\n public export\n data Reduces : (this : STLC ctxt type)\n -> (that : STLC ctxt type)\n -> Type\n where\n Refl : {this : STLC ctxt type}\n -> Reduces this this\n Trans : {this, that, end : STLC ctxt type}\n -> Redux this that\n -> Reduces that end\n -> Reduces this end\n\n public export\n data Finished : (term : STLC ctxt type)\n -> Type\n where\n Normalised : {term : STLC ctxt type}\n -> Value term\n -> Finished term\n OOF : Finished term\n\n public export\n data Evaluate : (term : STLC Nil type) -> Type where\n RunEval : {this, that : STLC 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 : forall type\n . (fuel : Fuel)\n -> (term : STLC 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 : forall type\n . (this : STLC Nil type)\n -> Maybe (Subset (STLC 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\nnamespace Example\n\n export\n example0 : STLC Nil BoolTy\n example0 = App (Func TyBool (Var Here) ChkBool) True\n\n export\n example1 : STLC Nil (FuncTy BoolTy BoolTy)\n example1 = (Func TyBool True ChkBool)\n\n export\n id : STLC Nil (FuncTy BoolTy BoolTy)\n id = (Func TyBool (Var Here) ChkBool)\n\n public export\n CBool : MTy VALUE\n CBool = FuncTy (FuncTy BoolTy BoolTy)\n (FuncTy BoolTy BoolTy)\n\n public export\n TyCBool : STLC ctxt (FuncTy (FuncTy BoolTyDesc BoolTyDesc)\n (FuncTy BoolTyDesc BoolTyDesc))\n TyCBool = TyFunc (TyFunc TyBool TyBool) (TyFunc TyBool TyBool)\n\n export\n zero : STLC ctxt CBool\n zero = Func (TyFunc TyBool TyBool)\n (Func TyBool\n (Var Here)\n ChkBool)\n (ChkFunc ChkBool ChkBool)\n\n export\n one : STLC ctxt CBool\n one = Func (TyFunc TyBool TyBool)\n (Func TyBool\n (App (Var (There Here)) (Var Here))\n ChkBool)\n (ChkFunc ChkBool ChkBool)\n\n export\n two : STLC ctxt CBool\n two = Func (TyFunc TyBool TyBool)\n (Func TyBool\n (App (Var (There Here))\n (App (Var (There Here)) (Var Here)))\n ChkBool)\n (ChkFunc ChkBool ChkBool)\n\n export\n succ : STLC ctxt (FuncTy CBool CBool)\n succ = Func TyCBool\n (Func (TyFunc TyBool TyBool)\n (Func TyBool\n ((Var (There Here)) `App`\n (((Var (There (There Here))) `App`\n (Var (There Here))) `App`\n (Var Here)))\n ChkBool)\n (ChkFunc ChkBool ChkBool))\n (ChkFunc (ChkFunc ChkBool ChkBool)\n (ChkFunc ChkBool ChkBool))\n\n export\n plus : STLC Nil (CBool `FuncTy` (CBool `FuncTy` CBool))\n plus = Func TyCBool\n (Func TyCBool\n (Func (TyFunc TyBool TyBool)\n (Func TyBool\n (App (App (Var (There (There (There Here))))\n (Var (There Here)))\n (App (App (Var (There (There Here))) (Var (There Here)))\n (Var Here)))\n ChkBool\n )\n (ChkFunc ChkBool ChkBool)\n )\n\n (ChkFunc (ChkFunc ChkBool ChkBool)\n (ChkFunc ChkBool ChkBool))\n )\n (ChkFunc (ChkFunc ChkBool ChkBool)\n (ChkFunc ChkBool ChkBool))\n\n-- --------------------------------------------------------------------- [ EOF ]\n", "meta": {"hexsha": "397a9bf8e8e95c5dc4b4fc24dff0272bce162ed3", "size": 13628, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Razor/STLC.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/STLC.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/STLC.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": 30.9727272727, "max_line_length": 93, "alphanum_fraction": 0.5216466099, "num_tokens": 3448, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333246077301781, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.596180425703241}}
{"text": "double : Num x => x -> x\ndouble x = x + x\n\ntwice : (a -> a) -> a -> a\ntwice f x = f (f x)\n\nShape : Type\nrotate : Shape -> Shape\n\nquadruple : Num a => a -> a\nquadruple = twice double\n\nturn_around : Shape -> Shape\nturn_around = twice rotate", "meta": {"hexsha": "fce3de27571a20cc4f2bd33100d2102ee364b034", "size": 238, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "ch02/HOF.idr", "max_stars_repo_name": "curtisalexander/tdd-idris", "max_stars_repo_head_hexsha": "f78c3d35a55db20d1793ed79d42190929ef4075b", "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": "ch02/HOF.idr", "max_issues_repo_name": "curtisalexander/tdd-idris", "max_issues_repo_head_hexsha": "f78c3d35a55db20d1793ed79d42190929ef4075b", "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": "ch02/HOF.idr", "max_forks_repo_name": "curtisalexander/tdd-idris", "max_forks_repo_head_hexsha": "f78c3d35a55db20d1793ed79d42190929ef4075b", "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.0, "max_line_length": 28, "alphanum_fraction": 0.6008403361, "num_tokens": 81, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.877476793890012, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.5959635474308127}}
{"text": "> module Basic.Operations\n\n\n> %default total\n\n> %access public export\n\n\n* Extensions of |replace|, |cong|\n\n> |||\n> replace2 : {a : _} -> {a1 : _} -> {a2 : _} ->\n> {b : _} -> {b1 : _} -> {b2 : _} ->\n> {P : a -> b -> Type} ->\n> (a1 = a2) -> (b1 = b2) -> P a1 b1 -> P a2 b2\n> replace2 Refl Refl p = p\n\n> |||\n> cong2 : {alpha : Type} ->\n> {beta : Type} ->\n> {gamma : Type} ->\n> {a1 : alpha} ->\n> {a2 : alpha} ->\n> {b1 : beta} ->\n> {b2 : beta} ->\n> {f : alpha -> beta -> gamma} ->\n> (a1 = a2) ->\n> (b1 = b2) ->\n> f a1 b1 = f a2 b2\n> cong2 Refl Refl = Refl\n\n> |||\n> depCong1 : {alpha : Type} ->\n> {P : alpha -> Type} ->\n> {a1 : alpha} ->\n> {a2 : alpha} ->\n> {f : (a : alpha) -> P a} ->\n> (a1 = a2) ->\n> f a1 = f a2\n> depCong1 Refl = Refl\n\n> |||\n> depCong2 : {alpha : Type} ->\n> {P : alpha -> Type} ->\n> {gamma : Type} ->\n> {a1 : alpha} ->\n> {a2 : alpha} ->\n> {Pa1 : P a1} ->\n> {Pa2 : P a2} ->\n> {f : (a : alpha) -> P a -> gamma} ->\n> (a1 = a2) ->\n> (Pa1 = Pa2) ->\n> f a1 Pa1 = f a2 Pa2\n> depCong2 Refl Refl = Refl\n\n> |||\n> depCong2' : {alpha : Type} ->\n> {P : alpha -> Type} ->\n> {Q : (a : alpha) -> P a -> Type} ->\n> {a1 : alpha} ->\n> {a2 : alpha} ->\n> {Pa1 : P a1} ->\n> {Pa2 : P a2} ->\n> {f : (a : alpha) -> (pa : P a) -> Q a pa} ->\n> (a1 = a2) ->\n> (Pa1 = Pa2) ->\n> f a1 Pa1 = f a2 Pa2\n> depCong2' Refl Refl = Refl\n", "meta": {"hexsha": "82b103380d92b757fb4810c5511c1e06525ca79f", "size": 1721, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "Basic/Operations.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": "Basic/Operations.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": "Basic/Operations.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": 24.9420289855, "max_line_length": 58, "alphanum_fraction": 0.3282975015, "num_tokens": 626, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672135527632, "lm_q2_score": 0.7371581568543043, "lm_q1q2_score": 0.5956733377569484}}
{"text": "import Data.List.Views\n\nmergeSort : Ord a => List a -> List a\nmergeSort input with (splitRec input)\n mergeSort [] | SplitRecNil = []\n mergeSort [x] | SplitRecOne = [x]\n mergeSort (lefts ++ rights) | (SplitRecPair lrec rrec) =\n merge (mergeSort lefts | lrec) (mergeSort rights | rrec)\n", "meta": {"hexsha": "ef26f0e551b1f14887df580c62650fe49bd69a34", "size": 290, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris-exercises/MergeSortView.idr", "max_stars_repo_name": "0nkery/tt-tutorials", "max_stars_repo_head_hexsha": "a39926989c2f39c718893b99bd857b6d51a172b0", "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-exercises/MergeSortView.idr", "max_issues_repo_name": "0nkery/tt-tutorials", "max_issues_repo_head_hexsha": "a39926989c2f39c718893b99bd857b6d51a172b0", "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-exercises/MergeSortView.idr", "max_forks_repo_name": "0nkery/tt-tutorials", "max_forks_repo_head_hexsha": "a39926989c2f39c718893b99bd857b6d51a172b0", "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.2222222222, "max_line_length": 60, "alphanum_fraction": 0.6793103448, "num_tokens": 89, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.7634837689358857, "lm_q1q2_score": 0.5955119192292379}}
{"text": "module Expr\n\n%default total\n\ndata Expr num = Val num\n | Add (Expr num) (Expr num)\n | Sub (Expr num) (Expr num)\n | Mul (Expr num) (Expr num)\n | Div (Expr num) (Expr num)\n | Abs (Expr num)\n\nNum ty => Num (Expr ty) where\n (+) = Add\n (*) = Mul\n fromInteger = Val . fromInteger\n\nNeg ty => Neg (Expr ty) where\n negate x = 0 - x\n (-) = Sub\n\nAbs ty => Abs (Expr ty) where\n abs = Abs\n\neval : (Abs num, Neg num, Integral num) => Expr num -> num\neval (Val n) = n\neval (Add x y) = eval x + eval y\neval (Sub x y) = eval x - eval y\neval (Mul x y) = eval x * eval y\neval (Div x y) = eval x `div` eval y\neval (Abs x) = abs (eval x)\n\ne1 : Expr Int\ne1 = Add (Val 6) (Mul (Val 3) (Val 12))\n", "meta": {"hexsha": "ae9110afcae60ff875684950a4bf6a91c5e0b004", "size": 742, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "chapter7/Expr.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": "chapter7/Expr.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": "chapter7/Expr.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": 21.8235294118, "max_line_length": 58, "alphanum_fraction": 0.5309973046, "num_tokens": 253, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.894789457685656, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.5954023470622912}}
{"text": "module OptimiseUnitary\n\nimport Data.Vect\nimport Data.Nat\nimport Unitary\n\n\n\nsimplify : Unitary n -> Unitary n -> (Unitary n, Bool)\nsimplify IdGate _ = (IdGate, False)\nsimplify _ IdGate = (IdGate, False)\nsimplify (H j x) (H k y) = \n if j == k then (y,True)\n else let (g,b) = simplify (H j x) y in (H k g, b)\nsimplify (H j x) (P p k y) = \n if j == k then (P p k y, False)\n else let (g,b) = simplify (H j x) y in (P p k g, b)\nsimplify (H j x) (CNOT c t y) = \n if j == c || j == t then (CNOT c t y, False)\n else let (g,b) = simplify (H j x) y in (CNOT c t g, b)\nsimplify (P p j x) (H k y) = \n if j == k then (H k y, False)\n else let (g,b) = simplify (P p j x) y in (H k g, b)\nsimplify (P p j x) (P p1 k y) = \n if j == k then (P (p + p1) k y, True)\n else let (g,b) = simplify (P p j x) y in (P p1 k g, b)\nsimplify (P p j x) (CNOT c t y) = \n if j == c || j == t then (CNOT c t y, False)\n else let (g,b) = simplify (P p j x) y in (CNOT c t g, b)\nsimplify (CNOT c t x) (H j y) = \n if j == c || j == t then (H j y, False)\n else let (g,b) = simplify (CNOT c t x) y in (H j g, b)\nsimplify (CNOT c t x) (P p j y) = \n if j == c || j == t then (P p j y, False)\n else let (g,b) = simplify (CNOT c t x) y in (P p j g, b)\nsimplify (CNOT c t x) (CNOT c1 t1 y) = \n if c == c1 && t == t1 then (y, True)\n else if c == c1 || t == t1 || c == t1 || t == c1 \n then (CNOT c1 t1 y, False)\n else let (g,b) = simplify (CNOT c t x) y in (CNOT c1 t1 g, b)\n\n\noptimise' : Unitary n -> (Unitary n, Bool)\noptimise' IdGate = (IdGate, False)\noptimise' (H j x) = \n let (g, b) = simplify (H j x) x \n (g1, b1) = optimise' g\n in if b then (g1, True)\n else (H j g1, b1)\noptimise' (P p j x) = \n let (g, b) = simplify (P p j x) x\n (g1, b1) = optimise' g\n in if b then (g1, True)\n else (P p j g1, b1)\noptimise' (CNOT c t x) = \n let (g, b) = simplify (CNOT c t x) x\n (g1, b1) = optimise' g\n in if b then (g1, True)\n else (CNOT c t g1, b1)\n\nexport\noptimise : Unitary n -> Unitary n\noptimise g = \n let (g1, b1) = optimise' g\n in if b1 then optimise g1\n else g1\n", "meta": {"hexsha": "e6246128d4cc0814b6b74ec1244d77c4888d1c21", "size": 2090, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "OptimiseUnitary.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": "OptimiseUnitary.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": "OptimiseUnitary.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": 31.1940298507, "max_line_length": 68, "alphanum_fraction": 0.5401913876, "num_tokens": 890, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339596505965, "lm_q2_score": 0.7090191214879991, "lm_q1q2_score": 0.5953874343551048}}
{"text": "-- Idea taken from http://liamoc.net/posts/2015-09-10-girards-paradox.html\n\n%default total\n\ndata Set : Type where\n MkSet : (x : Type) -> (x -> Set) -> Set\n\nIn : Set -> Set -> Type\nIn a (MkSet _ f) = (x ** a = f x)\n\nD : Set\nD = MkSet (s ** Not $ s `In` s) fst\n\nxind : x `In` D -> Not $ x `In` x\nxind ((_ ** f) ** Refl) = f\n\nxinx : {x : _} -> Not (x `In` x) -> x `In` D\nxinx f = ((_ ** f) ** Refl)\n\ndnotind : Not $ D `In` D\ndnotind dind = xind dind dind\n\nfalso : Void\nfalso = dnotind $ xinx dnotind\n", "meta": {"hexsha": "71e2ecb6903b047a9db0e0102c7eb89b6e8333cb", "size": 498, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Girard.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": "Girard.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": "Girard.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": 19.92, "max_line_length": 74, "alphanum_fraction": 0.546184739, "num_tokens": 209, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9136765187126079, "lm_q2_score": 0.6513548511303336, "lm_q1q2_score": 0.5951276328273323}}
{"text": "module adder\n\nadderTy : Nat -> Type\nadderTy Z = Nat \nadderTy (S k) = Nat -> adderTy k\n\nadder : (k : Nat) -> Nat -> adderTy k\nadder Z acc = acc\nadder (S k) acc = \\ x => adder k (x + acc)\n\n", "meta": {"hexsha": "b8a08b9b0aca612b9c5460affee02758ef35e4a1", "size": 191, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Intro/adder.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": "Intro/adder.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": "Intro/adder.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": 17.3636363636, "max_line_length": 42, "alphanum_fraction": 0.5706806283, "num_tokens": 71, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9032942067038785, "lm_q2_score": 0.6584175139669997, "lm_q1q2_score": 0.5947447259587608}}
{"text": "module DatatypeGeneric\n\ndata Data : Type where\n Unit : Data\n Zero : Data\n Param : Data\n Rec : Data\n Sum : Data -> Data -> Data\n Prod : Data -> Data -> Data\n\ninterp : Data -> Type -> Type -> Type\ninterp Unit param rec = ()\ninterp Zero param rec = Void\ninterp Param param rec = param\ninterp Rec param rec = rec\ninterp (Sum x y) param rec = Either (interp x param rec) (interp y param rec)\ninterp (Prod x y) param rec = (interp x param rec, interp y param rec)\n\ndata Mu : (dataF : Data) -> (a : Type) -> Type where\n In : interp dataF a (Mu dataF a) -> Mu dataF a\n\nbimap : (dataF : Data) -> (f : a -> b) -> (g : c -> d) -> interp dataF a c -> interp dataF b d\nbimap Unit f g () = ()\nbimap Param f g a = f a\nbimap Rec f g c = g c\nbimap (Sum x y) f g (Left l) = Left (bimap x f g l)\nbimap (Sum x y) f g (Right r) = Right (bimap y f g r)\nbimap (Prod x y) f g (a, b) = (bimap x f g a, bimap y f g b)\n\ninterface Representable (f : Type -> Type) where\n rep : Data\n fromRep : Mu rep a -> f a\n toRep : f a -> Mu rep a\n\nRepresentable List where\n rep = Sum Unit (Prod Param Rec)\n\n fromRep (In (Left ())) = []\n fromRep (In (Right (a, b))) = a :: fromRep b\n\n toRep [] = In (Left ())\n toRep (x :: xs) = In (Right (x, toRep xs))\n\ngmap : {dataF : Data} -> (a -> b) -> Mu dataF a -> Mu dataF b\ngmap {dataF = dataF} f (In x) = In $ bimap dataF f (gmap f) x\n\ngcata : {dataF : Data} -> (interp dataF a c -> c) -> Mu dataF a -> c\ngcata {dataF = dataF} f (In x) = f $ bimap dataF id (gcata f) x\n\nmap' : Representable f => (a -> b) -> f a -> f b\nmap' f fa = fromRep $ gmap f (toRep fa)\n\ntest : List Int\ntest = map' (\\x => x + 1) [1..10]\n", "meta": {"hexsha": "e27b08b13477dd7840b6b7fc8602c7c607cb1b62", "size": 1626, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/DatatypeGeneric.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/DatatypeGeneric.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/DatatypeGeneric.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": 29.5636363636, "max_line_length": 94, "alphanum_fraction": 0.5867158672, "num_tokens": 588, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357666736773, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.5947427116224193}}
{"text": "||| Additional data types related to ordering notions\nmodule Data.Order\n\n%default total\n\n||| Trichotomous formalises the fact that three relations are mutually exclusive.\n||| It is meant to be used with relations that complement each other so that the\n||| `Trichotomous lt eq gt` relation is the total relation.\npublic export\ndata Trichotomous : (lt, eq, gt : a -> a -> Type) -> (a -> a -> Type) where\n MkLT : {0 lt, eq, gt : a -> a -> Type} ->\n lt v w -> Not (eq v w) -> Not (gt v w) -> Trichotomous lt eq gt v w\n MkEQ : {0 lt, eq, gt : a -> a -> Type} ->\n Not (lt v w) -> eq v w -> Not (gt v w) -> Trichotomous lt eq gt v w\n MkGT : {0 lt, eq, gt : a -> a -> Type} ->\n Not (lt v w) -> Not (eq v w) -> gt v w -> Trichotomous lt eq gt v w\n", "meta": {"hexsha": "6d2c99ce538ad8eb0ef3ab97258e8f1a5c9e3e6f", "size": 783, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/contrib/Data/Order.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": "libs/contrib/Data/Order.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": "libs/contrib/Data/Order.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": 46.0588235294, "max_line_length": 82, "alphanum_fraction": 0.5862068966, "num_tokens": 255, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8670357529306639, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.5947426966289509}}
{"text": "> module InfiniteHorizonSequentialDecisionProblems.DeterministicTheory\n\n> import Data.Vect\n> import Syntax.PreorderReasoning\n\n> import Finite.Predicates\n> import Finite.Operations\n> import Finite.Properties\n> import Vect.Operations\n> import Vect.Properties\n\n> %default total\n> %access public export\n> %auto_implicits off\n\n* -----------------------------\n* Sequential decision processes\n* -----------------------------\n\n> State : Type\n> Ctrl : (x : State) -> Type\n> next : (x : State) -> (y : Ctrl x) -> State\n\n\n* ----------------------------\n* Sequential decision problems\n* ----------------------------\n\n> Val : Type\n> reward : (x : State) -> (y : Ctrl x) -> (x' : State) -> Val\n> (<+>) : Val -> Val -> Val\n> LTE : Val -> Val -> Type\n\n\n* --------\n* Policies\n* --------\n\n> Policy : Type\n> Policy = (x : State) -> Ctrl x\n\n\n* ---------------------\n* The value of policies\n* ---------------------\n\nThe value of making infinite many decision steps with a policy by\nstarting from a given state is given by a \"value\" function\n\n> val : Policy -> State -> Val\n\nthat fulfils the specification\n\n> valSpec : Type\n> valSpec = (p : Policy) -> (x : State) -> \n> val p x = reward x (p x) (next x (p x)) <+> val p (next x (p x))\n\nA naive attempt at implementing |val| directly \"from its specification\"\n\n< val p x = reward x (p x) (next x (p x)) <+> val p (next x (p x))\n\nyiels a possibly non total function. In contrast to SDPs with a finite\nnumber of decision steps, we cannot rely on an induction principle for\ndecision problems over an infinite number of steps. Obviously, there are\ncases in which |val| can be implemented. For instance, if all states\nhave the same successor. An important case is when |State| is finite. We\ndiscuss this case below.\n\n\n* ----------------------\n* Optimality of policies\n* ----------------------\n\n> Opt : Policy -> Type\n> Opt p = (p' : Policy) -> (x : State) -> val p' x `LTE` val p x\n\n\n* ----------------\n* Optimal policies\n* ----------------\n\nLet |LTE| be a preorder\n\n> reflexiveLTE : (a : Val) -> a `LTE` a\n> transitiveLTE : {a, b, c : Val} -> a `LTE` b -> b `LTE` c -> a `LTE` c\n\nand let |<+>| be monotonous w.r.t. |LTE|\n\n> monotonePlusLTE : {a, b, c, d : Val} -> a `LTE` b -> c `LTE` d -> (a <+> c) `LTE` (b <+> d)\n\nWe can compute the value of making a first decision step with a given\ncontrol and then infinitely many further steps with a given policy in\nterms of the (yet to be implemented) |val| function:\n\n> cval : (p : Policy) -> (x : State) -> Ctrl x -> Val\n> cval p x y = reward x y (next x y) <+> val p (next x y)\n\nAssume that, for an arbitrary policy |p| and for an arbitrary state |x|,\nwe can pick up a control that maximises |cval p x|:\n\n> cvalmax : (p : Policy) -> (x : State) -> Val\n> cvalargmax : (p : Policy) -> (x : State) -> Ctrl x\n\n> cvalargmaxSpec : (p : Policy) -> (x : State) -> cvalmax p x = cval p x (cvalargmax p x)\n> cvalmaxSpec : (p : Policy) -> (x : State) -> (y : Ctrl x) -> cval p x y `LTE` cvalmax p x\n\nThis is certainly the case if |Ctrl x| is non empty and finite for any\n|x| but there are more interesting cases in which we can compute \"best\"\ncontrols. In these cases, a policy\n\n> opt : Policy\n\nthat fulfils Bellman's equation\n\n> optSpec : Type\n> optSpec = (x : State) -> opt x = cvalargmax opt x \n\nis optimal\n\n> optLemma : (vs : valSpec) -> (os : optSpec) -> Opt opt\n\nAs in the case of |val|, we cannot implement |optLemma| in general. But\nit is useful to look at a (possibly non total) implementation:\n\n> optLemma vs os p' x = s9 where\n> s1 : val p' (next x (p' x)) `LTE` val opt (next x (p' x))\n> s1 = assert_total (optLemma vs os p' (next x (p' x)))\n> s2 : cval p' x (p' x) `LTE` cval opt x (p' x)\n> s2 = monotonePlusLTE (reflexiveLTE (reward x (p' x) (next x (p' x)))) s1\n> s3 : cval opt x (p' x) `LTE` cvalmax opt x\n> s3 = cvalmaxSpec opt x (p' x)\n> s4 : cvalmax opt x = cval opt x (cvalargmax opt x)\n> s4 = cvalargmaxSpec opt x\n> s5 : cval opt x (cvalargmax opt x) = cval opt x (opt x)\n> s5 = replace {P = \\ U => cval opt x U = cval opt x (opt x)} (os x) Refl\n> s6 : cval opt x (opt x) = val opt x\n> s6 = sym (vs opt x)\n> s7 : cval p' x (p' x) `LTE` cvalmax opt x\n> s7 = transitiveLTE s2 s3\n> s8 : val p' x `LTE` cvalmax opt x\n> s8 = replace {P = \\ W => W `LTE` cvalmax opt x} (sym (vs p' x)) s7\n> s9 : val p' x `LTE` val opt x\n> s9 = replace {P = \\ W => val p' x `LTE` W} (trans (trans s4 s5) s6) s8\n\n\n* -------------------------\n* The case of finite states\n* -------------------------\n\nIf |State| is finite\n\n> finiteState : Finite State\n\nwe can compute the number of values of type |State| \n\n> cardState : Nat\n> cardState = card finiteState\n\nand collect them in a vector\n\n> vectState : Vect cardState State\n> vectState = toVect finiteState\n\nThis representation of |State| is guaranteed to be complete\n\n> completeVectState : (x : State) -> Elem x vectState\n> completeVectState = toVectComplete finiteState\n\nand injective\n\n> inj1VectState : Injective1 vectState\n> inj1VectState = toVectInjective1 finiteState\n\n> inj2VectState : Injective2 vectState\n> inj2VectState = injectiveLemma vectState inj1VectState\n\nby construction. We can also represent the value of a policy by a value\ntable\n\n> vt : Policy -> Vect cardState Val\n\nand implement |val| in terms of the values of the table\n\n> val p x = index k (vt p) where\n> k : Fin cardState\n> k = lookup x vectState (completeVectState x)\n\nIn this case, the specification of |val| defines a linear system of\nequations for the components of the value table. To derive these\nequations, consider, first the representation of |next|\n\n> nextR : (k : Fin cardState) -> (y : Ctrl (index k vectState)) -> Fin cardState\n> nextR k y = lookup x' vectState (completeVectState x') where\n> x' : State\n> x' = next (index k vectState) y\n\n|nextR| is a representations of |next| in the sense that\n\n> nextLemma : (k : Fin cardState) -> (y : Ctrl (index k vectState)) ->\n> index (nextR k y) vectState = next (index k vectState) y\n\nA proof of |nextLemma| is straightforward, see Appendix below. It is\nalso useful to define a representation for the reward function\n\n> rewardR : (k : Fin cardState) -> (y : Ctrl (index k vectState)) -> Val\n> rewardR k y = reward x y (next x y) where\n> x : State\n> x = index k vectState\n\nand for policies:\n\n> pR : (p : Policy) -> (k : Fin cardState) -> Ctrl (index k vectState)\n> pR p k = p (index k vectState) \n\nWith |nextR|, |rewardR| and |pR|, we can derive the system of equations for\nthe components of |vt| by rewriting |valSpec p| for each component of\n|vectState|:\n\n> equation : (vs : valSpec) -> (p : Policy) -> (k : Fin cardState) -> \n> index k (vt p) \n> = \n> rewardR k (pR p k) <+> index (nextR k (pR p k)) (vt p)\n\nTo derive |equation|, it is useful to prove three intermediate results:\n\n> lemma1 : (p : Policy) -> (k : Fin cardState) -> index k (vt p) = val p (index k vectState)\n\n> lemma2 : (p : Policy) -> (k : Fin cardState) -> \n> reward (index k vectState) (p (index k vectState)) (next (index k vectState) (p (index k vectState)))\n> =\n> rewardR k (pR p k)\n\n> lemma3 : (p : Policy) -> (k : Fin cardState) -> \n> val p (next (index k vectState) (p (index k vectState)))\n> =\n> index (nextR k (pR p k)) (vt p)\n\nThe implementations are given in the Appendix. With these lemmas, the\nimplementation of |equation| is directly follows from the definition of\n|valSpec|:\n\n> equation vs p k = let x = index k vectState in\n> ( index k (vt p) )\n> ={ lemma1 p k }=\n> ( val p x )\n> ={ vs p x }=\n> ( reward x (p x) (next x (p x)) <+> val p (next x (p x)) )\n> ={ replace {P = \\ W => reward x (p x) (next x (p x)) <+> val p (next x (p x)) = W <+> val p (next x (p x))} (lemma2 p k) Refl }=\n> ( rewardR k (pR p k) <+> val p (next x (p x)) )\n> ={ replace {P = \\ W => rewardR k (pR p k) <+> val p (next x (p x)) = rewardR k (pR p k) <+> W} (lemma3 p k) Refl }=\n> ( rewardR k (pR p k) <+> index (nextR k (pR p k)) (vt p) )\n> QED\n\n\n* --------\n* Appendix\n* --------\n\n> nextLemma k y = ( index (nextR k y) vectState )\n> ={ Refl }=\n> ( index (lookup (next (index k vectState) y) vectState (completeVectState (next (index k vectState) y))) vectState )\n> ={ indexLookupLemma (next (index k vectState) y) vectState (completeVectState (next (index k vectState) y)) }=\n> ( next (index k vectState) y )\n> QED\n\n> lemma1 p k = ( index k (vt p) )\n> ={ replace {P = \\ W => index k (vt p) = index W (vt p)} (sym (lookupIndexLemma k vectState inj2VectState (toVectComplete finiteState (index k vectState)))) Refl }=\n> ( index (lookup (index k vectState) vectState (toVectComplete finiteState (index k vectState))) (vt p) )\n> ={ Refl }=\n> ( val p (index k vectState) )\n> QED\n\n> lemma2 p k = Refl\n\n> lemma3 p k = ( val p (next (index k vectState) (p (index k vectState))) )\n> ={ Refl }= -- def. pR\n> ( val p (next (index k vectState) (pR p k)) )\n> ={ Refl }= -- def. val\n> ( index (lookup (next (index k vectState) (pR p k)) vectState (completeVectState (next (index k vectState) (pR p k)))) (vt p) )\n> ={ Refl }= -- def. nextR\n> ( index (nextR k (pR p k)) (vt p) )\n> QED\n\n\n> {-\n\n> ---}\n\n\n \n \n", "meta": {"hexsha": "35e4e01ad3541974e4d4c6bef049fde34f8fcbdf", "size": 9649, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "InfiniteHorizonSequentialDecisionProblems/DeterministicTheory.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": "InfiniteHorizonSequentialDecisionProblems/DeterministicTheory.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": "InfiniteHorizonSequentialDecisionProblems/DeterministicTheory.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.0445205479, "max_line_length": 176, "alphanum_fraction": 0.5759146025, "num_tokens": 3007, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430478583169, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.5946196803664516}}
{"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 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 (ty, Vect outHeight Integer)\nrunStack stk (Push x) = ((), x :: stk)\nrunStack (x :: xs) Pop = (x, xs)\nrunStack (x :: xs) Top = (x, x :: xs)\nrunStack stk (Pure x) = (x, stk)\nrunStack stk (x >>= f)\n = let (res, stk') = runStack stk x in\n runStack stk' (f res)\n\ntestAdd : StackCmd Integer 0 0\ntestAdd = do Push 10\n Push 20\n val1 <- Pop\n val2 <- Pop\n Pure (val1 + val2)\n\ndoAdd : StackCmd () (S (S height)) (S height)\ndoAdd = do val1 <- Pop\n val2 <- Pop\n Push $ val1 + val2\n", "meta": {"hexsha": "2c81a4422f707dcf998b23be772fdc39a2e7fc30", "size": 1119, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "chapter13/Stack.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/Stack.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/Stack.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.975, "max_line_length": 51, "alphanum_fraction": 0.5737265416, "num_tokens": 345, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256393148982, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.5941479270681141}}
{"text": "> module SequentialDecisionGames.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\nFor the time being, we just consider two players: player 1 and player 2\n\n\n\n* Sequential decision processes\n\n> State : (t : Nat) -> Type\n\n|Ctrl1 t x| and |Ctrl2 t x| are the controls available to player 1 and\n to player 2 at decision step |t| and in state |x|:\n\n> Ctrl1 : (t : Nat) -> (x : State t) -> Type\n\n> Ctrl2 : (t : Nat) -> (x : State t) -> Type\n\n> Ctrls : (t : Nat) -> (x : State t) -> Type\n> Ctrls t x = (Ctrl1 t x, Ctrl2 t x)\n\n> M : Type -> Type\n\n> nexts : (t : Nat) -> (x : State t) -> (ys : Ctrls t x) -> M (State (S t))\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\n\n\n* Sequential decision problems\n\n> Val : Type\n\n> Vals : Type\n> Vals = (Val, Val) \n\n> reward : (t : Nat) -> (x : State t) -> (ys : Ctrls t x) -> (x' : State (S t)) -> Vals\n\n> plus : Val -> Val -> Val\n\n> zero : Val\n\n> LTE : Val -> Val -> Type\n\n> meas1 : M Val -> Val\n\n> meas2 : M Val -> Val\n\n\n\n* Solving sequential decision problems\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\n\n\n* Viability\n\n> Viable : {t : Nat} -> (n : Nat) -> State t -> Type\n\n> postulate viableSpec0 : {t : Nat} ->\n> (x : State t) -> Viable Z x\n\n> Good : (t : Nat) -> (x : State t) -> (n : Nat) -> (ys : Ctrls t x) -> Type\n> Good t x n ys = (NotEmpty (nexts t x ys), All (Viable {t = S t} n) (nexts t x ys))\n\n> GoodCtrls : (t : Nat) -> (x : State t) -> (n : Nat) -> Type\n> GoodCtrls t x n = Sigma (Ctrls t x) (Good t x n)\n\n> viableSpec1 : {t : Nat} -> {n : Nat} ->\n> (x : State t) -> Viable (S n) x -> GoodCtrls t x n\n\n> postulate viableSpec2 : {t : Nat} -> {n : Nat} ->\n> (x : State t) -> GoodCtrls t x n -> Viable (S n) x\n\n> ctrls : {t, n : Nat} -> {x : State t} -> GoodCtrls t x n -> Ctrls t x\n> ctrls (MkSigma ys _) = ys\n\n> allViable : {t, n : Nat} -> {x : State t} -> \n> (gys : GoodCtrls t x n) -> \n> All (Viable {t = S t} n) (nexts t x (ctrls gys)) \n> allViable (MkSigma _ p) = snd p\n\n\n\n* Reachability\n\n> Reachable : {t' : Nat} -> State t' -> Type\n\n> postulate reachableSpec0 : (x : State Z) -> Reachable x\n\n> reachableSpec1 : {t : Nat} -> \n> (x : State t) -> \n> Reachable x -> \n> (ys : Ctrls t x) -> \n> All Reachable (nexts t x ys)\n\n> {-\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> 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\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> backwardsInduction t (S n) = optExt ps :: ps where\n> ps : PolicySeq (S t) n\n> ps = backwardsInduction (S t) n\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", "meta": {"hexsha": "c8850944bebf1a7e7359f0fbe1014f98ec109df3", "size": 15580, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "SequentialDecisionGames/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": "SequentialDecisionGames/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": "SequentialDecisionGames/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": 35.3287981859, "max_line_length": 127, "alphanum_fraction": 0.5823491656, "num_tokens": 4974, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199754937771, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.593888584315543}}
{"text": "module Bowling\n\n %default total\n\nnamespace cst\n\n pinsNumber : Nat\n pinsNumber = 10\n\n totalFrames : Nat\n totalFrames = 10\n\ndata FrameStatus = Incomplete Nat\n | ExtraRoll1 Nat\n | ExtraRoll2 Nat Nat\n\ndata Frame = Normal Nat Nat\n | Spare Nat\n | Strike\n | LastSpecial Nat Nat Nat\n\ndata Game : (toBeCompleted : Nat) -> Type where\n NewGame : Game 10\n CompletedFrame : (frame : Frame) -> (game : Game (S tbc)) -> Game tbc\n OngoingFrame : FrameStatus -> Game (S tbc) -> Game (S tbc)\n\n\n\nisLastFrame : (completed : Nat) -> Dec (completed = 0)\nisLastFrame completed = decEq completed 0\n\nisSpare : (first : Nat) -> (second : Nat) -> Dec (first + second = cst.pinsNumber)\nisSpare first second = decEq (first + second) pinsNumber\n\nisStrike : (first : Nat) -> Dec (first = cst.pinsNumber)\nisStrike first = decEq first pinsNumber\n\naddFrame : (completed : List Frame) -> (newFrame : Frame) -> List Frame\naddFrame completed newFrame = completed ++ [newFrame]\n\nrolls : Game (S n) -> Nat -> Either (Game (S n)) (Game n)\n\nrolls NewGame k with (isStrike k)\n | (Yes _) = Right (CompletedFrame Strike NewGame)\n | (No _) = Left (OngoingFrame (Incomplete k) NewGame)\n\nrolls (CompletedFrame frame game) k {n} with (isStrike k)\n | (No _) = Left (OngoingFrame (Incomplete k) (CompletedFrame frame game))\n | (Yes _) with (isLastFrame n)\n | (Yes _) = Left (OngoingFrame (ExtraRoll1 k) (CompletedFrame frame game))\n | (No _) = Right (CompletedFrame Strike (CompletedFrame frame game))\n\nrolls (OngoingFrame (Incomplete j) y) k {n} with (isSpare j k)\n | (Yes _) with (isLastFrame n)\n | (Yes _) = Left (OngoingFrame (ExtraRoll2 j k) (OngoingFrame (Incomplete j) y))\n | (No _) = Right (CompletedFrame (Spare j) (OngoingFrame (Incomplete j) y))\n | (No _) = Right (CompletedFrame (Normal j k) (OngoingFrame (Incomplete j) y))\n\nrolls (OngoingFrame (ExtraRoll1 j) y) k = Left (OngoingFrame (ExtraRoll2 j k) (OngoingFrame (ExtraRoll1 j) y))\n\nrolls (OngoingFrame (ExtraRoll2 j i) y) k = Right (CompletedFrame (LastSpecial j i k) (OngoingFrame (ExtraRoll2 j i) y))\n\nlistRolls : List Frame -> List Nat\nlistRolls [] = []\nlistRolls ((Normal k j) :: xs) = k::j::listRolls xs\nlistRolls ((Spare k) :: xs) = k :: minus 10 k :: listRolls xs\nlistRolls (Strike :: xs) = pinsNumber::listRolls xs\nlistRolls (LastSpecial k j i :: xs) = k::j::i::listRolls xs\n\nbonus : (numberOfRolls : Nat) -> (xs : List Frame) -> Nat\nbonus n = sum . take n . listRolls\n\nscoreFrames : (xs : List Frame) -> Nat\nscoreFrames [] = 0\nscoreFrames ((Normal k j) :: xs) = k + j + scoreFrames xs\nscoreFrames ((Spare _) :: xs) = pinsNumber + bonus 1 xs + scoreFrames xs\nscoreFrames (Strike :: xs) = pinsNumber + bonus 2 xs + scoreFrames xs\nscoreFrames (LastSpecial k j i :: xs) = k + j + i + scoreFrames xs\n\nlistFrames : Game n -> List Frame\nlistFrames NewGame = []\nlistFrames (CompletedFrame frame game) = listFrames game ++ [frame]\nlistFrames (OngoingFrame x game) = listFrames game\n\nscore : Game Z -> Nat\nscore = scoreFrames . listFrames\n\n-- Test\n\nreplay : List Nat -> Maybe (n ** Game n)\nreplay = foldlM go (_ ** NewGame)\n where\n\n go : (n : Nat ** Game n) -> Nat -> Maybe (n' : Nat ** Game n')\n go (Z ** game) k = Nothing\n go ((S n) ** game) k = either (\\g => (Just (_ ** g))) (\\g => (Just (_ ** g))) $ rolls game k\n\nscore' : Maybe (n ** Game n) -> Maybe Nat\nscore' Nothing = Nothing\nscore' (Just ((S _) ** _)) = Nothing\nscore' (Just (Z ** game)) = Just (score game)\n\n--\n\nallInTheGuttersScoresZero : score' (replay (replicate 20 0)) = Just 0\nallInTheGuttersScoresZero = Refl\n\nallOneDownsScores20 : score' (replay (replicate 20 1)) = Just 20\nallOneDownsScores20 = Refl\n\nstrikeScoringIsOK : score' (replay (10::3::6::replicate 16 0)) = Just 28\nstrikeScoringIsOK = Refl\n\nperfectScoreIs300 : score' (replay (replicate 12 10)) = Just 300\nperfectScoreIs300 = Refl\n\nlastFrameSpareScoresIsOk : score' (replay (replicate 18 0 ++ [5,5,3])) = Just 13\nlastFrameSpareScoresIsOk = Refl\n\n\nspareScoringIsOK : (notStrike : Not (fstRoll = 10))\n -> (spareProof : (fstRoll + sndRoll = 10))\n -> (thirdNotStrike : Not (thirdRoll = 10))\n -> score' (replay (fstRoll::sndRoll::thirdRoll::replicate 17 0)) = Just ((fstRoll + sndRoll + thirdRoll) + thirdRoll)\nspareScoringIsOK notStrike spareProof thirdNotStrike {fstRoll} {sndRoll} {thirdRoll} with (isStrike fstRoll)\n | (Yes prf) = void (notStrike prf)\n | (No _) with (isSpare fstRoll sndRoll)\n | (No notASpare) = void (notASpare spareProof)\n | (Yes _) with (isStrike thirdRoll)\n | (Yes prf) = void (thirdNotStrike prf)\n | (No _) with (isSpare thirdRoll 0)\n | (Yes secondFrameIsASpare) = void (thirdNotStrike (rewrite sym (plusZeroRightNeutral thirdRoll) in secondFrameIsASpare))\n | (No _) = rewrite spareProof in rewrite (plusZeroRightNeutral thirdRoll) in rewrite (plusZeroRightNeutral thirdRoll) in Refl\n\n", "meta": {"hexsha": "90862f9ce0dfb02f3c7b321feefb9ed28a27ae10", "size": 4947, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "01-TestDD-in-Idris/Bowling.idr", "max_stars_repo_name": "berewt/live-coding", "max_stars_repo_head_hexsha": "7d2d7324cf503e5957bd689f37d18992d78844dc", "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": "01-TestDD-in-Idris/Bowling.idr", "max_issues_repo_name": "berewt/live-coding", "max_issues_repo_head_hexsha": "7d2d7324cf503e5957bd689f37d18992d78844dc", "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": "01-TestDD-in-Idris/Bowling.idr", "max_forks_repo_name": "berewt/live-coding", "max_forks_repo_head_hexsha": "7d2d7324cf503e5957bd689f37d18992d78844dc", "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": 36.6444444444, "max_line_length": 134, "alphanum_fraction": 0.6587831009, "num_tokens": 1541, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.837619947119304, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.5938885744977901}}
{"text": "module Biapplicative\n\nimport Bifunctor\nimport Apply\n\ninfixl 4 <<*>>, <<*, *>>, <<**>>\n\n||| Biapplicatives\n||| @p the action of the Biapplicative on pairs of objects\npublic export\ninterface Bifunctor p => Biapplicative p where -- (p : Type -> Type -> Type) where\n\n ||| Lifts two values into a Biapplicative\n |||\n ||| ````idris example\n ||| bipure 1 \"hello\" = (1, \"hello\")\n ||| ````\n |||\n bipure : a -> b -> p a b\n\n ||| Applies a Biapplicative of functions to a second Biapplicative\n |||\n ||| ````idris example\n ||| ( (\\x => x + 1), reverse ) <<*>> (1, \"hello\") == (2, \"olleh\")\n ||| ````\n |||\n (<<*>>) : p (a -> b) (c -> d) -> p a c -> p b d\n\n ||| Sequences two Biapplicatives rightwards\n |||\n ||| ````idris example\n ||| (1, \"hello\") *>> (2, \"goodbye\") = (2, \"goodbye\")\n ||| ````\n |||\n (*>>) : p a b -> p c d -> p c d\n a *>> b = bimap (const id) (const id) <<$>> a <<*>> b\n\n ||| Sequences two Biapplicatives leftwards\n |||\n ||| ````idris example\n ||| (1, \"hello\") <<* (2, \"goodbye\") = (1, \"hello\")\n ||| ````\n |||\n (<<*) : p a b -> p c d -> p a b\n a <<* b = bimap const const <<$>> a <<*>> b\n\n||| Applies the second of two Biapplicatives to the first\n|||\n||| ````idris example\n||| (1, \"hello\") <<**>> ( (\\x => x + 1), reverse ) == (2, \"olleh\")\n||| ````\n|||\nexport\n(<<**>>) : Biapplicative p => p a c -> p (a -> b) (c -> d) -> p b d\n(<<**>>) = flip (<<*>>)\n\nexport\nbiliftA2 : Biapplicative p => (a -> b -> c) ->\n (d -> e -> f) -> p a d -> p b e -> p c f\nbiliftA2 f g a b = bimap f g <<$>> a <<*>> b\n\nexport\nbiliftA3 : Biapplicative p =>\n (a -> b -> c -> d) -> (e -> f -> g -> h) -> p a e -> p b f -> p c g -> p d h\nbiliftA3 f g a b c = bimap f g <<$>> a <<*>> b <<*>> c\n\npublic export\nimplementation Biapplicative Pair where\n bipure a b = (a, b)\n (f, g) <<*>> (a, b) = (f a, g b)\n", "meta": {"hexsha": "0168d19fb36f8a185e595163aea86fca21a5b394", "size": 1847, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/interface006/Biapplicative.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/interface006/Biapplicative.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/interface006/Biapplicative.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": 26.014084507, "max_line_length": 82, "alphanum_fraction": 0.4667027612, "num_tokens": 716, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.833324587033253, "lm_q2_score": 0.712232184238947, "lm_q1q2_score": 0.5935205908027122}}
{"text": "module AutoF\n\nimport Data.So\nimport Data.Vect\nimport Data.Vect.Quantifiers\n\n%default total\n\nnotEq : Eq a -> (x : a) -> (y : a) -> Type\nnotEq eq x y = So (x /= y)\n\nmutual\n ||| Uqtor (uniquetor), a vector with unique values (according to `Eq`)\n data Uqt : (n : Nat) -> (a : Type) -> {auto eq : Eq a} -> Type where\n Nil : Eq a => Uqt Z a\n (::) : (x : a) -> (xs : Uqt n a {eq}) -> {auto unq : All (notEq eq x) (unUqt xs)} -> Uqt (S n) a\n\n unUqt : Uqt n a {eq} -> Vect n a\n unUqt Nil = Nil\n unUqt (x::xs) = x::(unUqt xs)\n\nsummon : {auto u : a} -> a\nsummon {u} = u\n\ndata X = A | B | C\n\nEq X where\n A == A = True\n B == B = True\n C == C = True\n _ == _ = False\n\n-- just testing Uqt\nuS : Uqt 3 String\nuS = [\"a\", \"b\", \"c\"]\n\n-- just testing Uqt\nuX : Uqt 3 X\nuX = [A, B, C]\n\n%hint\na : X\na = A\n\n%hint\nb : X\nb = B\n\n%hint\nc : X\nc = C\n\ny0 : Uqt 0 X\ny0 = summon\n\nyF : Uqt 1 X\nyF = summon\n\nyG : Uqt 2 X\nyG = ?yG_rhs\n\nyHint : Uqt 3 X\nyHint = ?yHint_rhs\n\nyLoc : Uqt 3 X\nyLoc =\n let a = A in\n let b = B in\n let c = C in\n ?yLoc_rhs\n", "meta": {"hexsha": "d578211ce625e588f73265a95e0693c9ce3874ce", "size": 1033, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "AutoF.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": "AutoF.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": "AutoF.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": 14.5492957746, "max_line_length": 100, "alphanum_fraction": 0.527589545, "num_tokens": 462, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8652240825770432, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.5934999823488613}}
{"text": "-- Minimal implicational logic, PHOAS approach, initial encoding\n\nmodule STLC\n\n%default total\n\n\n-- Types\n\ninfixr 0 :=>\n\ndata Ty : Type where\n UNIT : Ty\n (:=>) : Ty -> Ty -> Ty\n\n\n-- Context\n\nCx : Type\nCx = Ty -> Type\n\n\n-- Terms\n\ninfixl 1 :$\n\ndata Tm : Cx -> Ty -> Type\n where\n var : tc a\n ----------\n -> Tm tc a\n\n lam : (tc a -> Tm tc b)\n --------------------\n -> Tm tc (a :=> b)\n\n (:$) : Tm tc (a :=> b) -> Tm tc a\n ----------------------------\n -> Tm tc b\n\nT : Ty -> Type\nT a = {tc : Cx} -> Tm tc a\n\n\n-- Example theorems\n\nI : T (a :=> a)\nI = lam $ \\x =>\n var x\n\nK : T (a :=> b :=> a)\nK = lam $ \\x =>\n lam $ \\_ =>\n var x\n\nS : T ((a :=> b :=> c) :=> (a :=> b) :=> a :=> c)\nS = lam $ \\f =>\n lam $ \\g =>\n lam $ \\x =>\n (var f :$ var x) :$ (var g :$ var x)\n\nSKK : T (a :=> a)\nSKK {a} =\n S {b = a :=> a} :$ K :$ K\n", "meta": {"hexsha": "440e8c5507d1464bdab9387756fc1b9016922a11", "size": 933, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/STLC.idr", "max_stars_repo_name": "mietek/haskell-exchange-2015", "max_stars_repo_head_hexsha": "3f8e19674283d64d6c7e50f66a3e8f33138e9195", "max_stars_repo_licenses": ["X11"], "max_stars_count": 10, "max_stars_repo_stars_event_min_datetime": "2015-10-09T09:19:22.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-19T18:09:21.000Z", "max_issues_repo_path": "src/STLC.idr", "max_issues_repo_name": "mietek/haskell-exchange-2015", "max_issues_repo_head_hexsha": "3f8e19674283d64d6c7e50f66a3e8f33138e9195", "max_issues_repo_licenses": ["X11"], "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/STLC.idr", "max_forks_repo_name": "mietek/haskell-exchange-2015", "max_forks_repo_head_hexsha": "3f8e19674283d64d6c7e50f66a3e8f33138e9195", "max_forks_repo_licenses": ["X11"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 14.3538461538, "max_line_length": 64, "alphanum_fraction": 0.3515541265, "num_tokens": 342, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110368115781, "lm_q2_score": 0.6654105653819836, "lm_q1q2_score": 0.5934204862186853}}
{"text": "module Toolkit.Data.DList.Any\n\nimport Toolkit.Decidable.Informative\n\nimport Toolkit.Data.DList\n\nimport public Toolkit.Decidable.Equality.Indexed\n\n%default total\n\n||| Proof that some element satisfies the predicate\n|||\n||| @idx The type of the element's index.\n||| @type The type of the list element.\n||| @p A predicate\n||| @xs The list itself.\npublic export\ndata Any : (idx : Type)\n -> (type : idx -> Type)\n -> (p : {i : idx} -> (x : type i) -> Type)\n -> {is : List idx}\n -> (xs : DList idx type is)\n -> Type\n where\n ||| Proof that the element is at the front of the list.\n H : {p : {i : idx} -> (x : type i) -> Type}\n -> {i : idx}\n -> {y : type i}\n -> (prf : p y)\n -> Any idx type p (y :: xs)\n\n ||| Proof that the element is found later in the list.\n T : {p : {i : idx} -> (x : type i) -> Type}\n -> (contra : p x' -> Void)\n -> (later : Any idx type p xs)\n -> Any idx type p (x' ::xs)\n\nempty : {p : {i : idx} -> (x : type i) -> Type} -> Any idx type p Nil -> Void\nempty (H prf) impossible\nempty (T contra later) impossible\n\n\nisNotThere : {p : {i : idx} -> (x : type i) -> Type}\n -> (Any idx type p rest -> Void)\n -> (p i -> Void)\n -> Any idx type p (i :: rest) -> Void\nisNotThere f g (H prf) = g prf\nisNotThere f g (T contra later) = f later\n\nexport\nany : {p : {i : idx} -> (x : type i) -> Type}\n -> (f : {i : idx} -> (x : type i) -> DecInfo err (p x))\n -> (xs : DList idx type is)\n -> Dec (Any idx type p xs)\nany f [] = No empty\n\nany f (elem :: rest) with (f elem)\n any f (elem :: rest) | (Yes prfWhy)\n = Yes (H prfWhy)\n\n any f (elem :: rest) | (No msgWhyNot prfWhyNot) with (any f rest)\n any f (elem :: rest) | (No msgWhyNot prfWhyNot) | (Yes prfWhy)\n = Yes (T prfWhyNot prfWhy)\n any f (elem :: rest) | (No msgWhyNot prfWhyNot) | (No g)\n = No (isNotThere g prfWhyNot)\n\n-- [ EOF ]\n", "meta": {"hexsha": "6f691263513028eac1576c5b593c0e8f45365d45", "size": 2008, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Toolkit/Data/DList/Any.idr", "max_stars_repo_name": "border-patrol/linear-circuits", "max_stars_repo_head_hexsha": "e6eb41dc07830d2e337acfad5b087fcc81479aa9", "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/DList/Any.idr", "max_issues_repo_name": "border-patrol/linear-circuits", "max_issues_repo_head_hexsha": "e6eb41dc07830d2e337acfad5b087fcc81479aa9", "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/DList/Any.idr", "max_forks_repo_name": "border-patrol/linear-circuits", "max_forks_repo_head_hexsha": "e6eb41dc07830d2e337acfad5b087fcc81479aa9", "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.5294117647, "max_line_length": 77, "alphanum_fraction": 0.5169322709, "num_tokens": 648, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677737461007, "lm_q2_score": 0.6992544147913994, "lm_q1q2_score": 0.5929452093927954}}
{"text": "data Tree elem = Empty\n | Node (Tree elem) elem (Tree elem)\n\n%name Tree tree, tree1\n\ninsert : Ord elem => elem -> Tree elem -> Tree elem\ninsert x Empty = Node Empty x Empty\ninsert x orig@(Node left val right) = case compare x val of\n LT => Node (insert x left) val right\n EQ => orig\n GT => Node left val (insert x right)\n", "meta": {"hexsha": "a44b665956b5d7a1d25b89d6d9ab7feda2acc3ec", "size": 446, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Tree.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": "Tree.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": "Tree.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": 37.1666666667, "max_line_length": 74, "alphanum_fraction": 0.4887892377, "num_tokens": 92, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8438951182587158, "lm_q2_score": 0.7025300449389326, "lm_q1q2_score": 0.5928616753540414}}
{"text": "import Data.Vect\n\nappend : (elem : Type) -> (n : Nat) -> (m : Nat) ->\n Vect n elem -> Vect m elem -> Vect (n + m) elem\nappend elem Z m [] ys = ys\nappend elem (S k) m (x :: xs) ys = x :: append elem k m xs ys\n\ncreateEmpties : Vect n (Vect 0 a)\ncreateEmpties {n = Z} = []\ncreateEmpties {n = (S k)} = [] :: createEmpties\n", "meta": {"hexsha": "458db8d35d761f24e4567ce3d11109ad27805684", "size": 326, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Append.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": "Append.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": "Append.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": 29.6363636364, "max_line_length": 61, "alphanum_fraction": 0.5613496933, "num_tokens": 117, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8558511469672594, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.5927984248434941}}
{"text": "= Poly : Polymorphism and Higher-Order Functions\n\n> module Poly\n\n> import Basics\n\n> %hide Prelude.List.length\n> %hide Prelude.List.filter\n> %hide Prelude.List.partition\n> %hide Prelude.Functor.map\n> %hide Prelude.Nat.pred\n> %hide Basics.Playground2.plus\n\n> %access public export\n\n> %default total\n\n\n== Polymorphism\n\nIn this chapter we continue our development of basic concepts of functional\nprogramming. The critical new ideas are _polymorphism_ (abstracting functions\nover the types of the data they manipulate) and _higher-order functions_\n(treating functions as data). We begin with polymorphism.\n\n\n=== Polymorphic Lists\n\nFor the last couple of chapters, we've been working just with lists of numbers.\nObviously, interesting programs also need to be able to manipulate lists with\nelements from other types -- lists of strings, lists of booleans, lists of\nlists, etc. We _could_ just define a new inductive datatype for each of these,\nfor example...\n\n> data BoolList : Type where\n> BoolNil : BoolList\n> BoolCons : Bool -> BoolList -> BoolList\n\n... but this would quickly become tedious, partly because we have to make up\ndifferent constructor names for each datatype, but mostly because we would also\nneed to define new versions of all our list manipulating functions\n(\\idr{length}, \\idr{rev}, etc.) for each new datatype definition.\n\nTo avoid all this repetition, Idris supports _polymorphic_ inductive type\ndefinitions. For example, here is a _polymorphic list_ datatype.\n\n```idris\ndata List : (x : Type) -> Type where\n Nil : List x\n Cons : x -> List x -> List x\n```\n\n(This type is already defined in Idris' standard library, but the \\idr{Cons}\nconstructor is named \\idr{(::)}).\n\nThis is exactly like the definition of \\idr{NatList} from the previous chapter,\nexcept that the \\idr{Nat} argument to the \\idr{Cons} constructor has been\nreplaced by an arbitrary type \\idr{x}, a binding for \\idr{x} has been added to\nthe header, and the occurrences of \\idr{NatList} in the types of the\nconstructors have been replaced by \\idr{List x}. (We can re-use the constructor\nnames \\idr{Nil} and \\idr{Cons} because the earlier definition of \\idr{NatList}\nwas inside of a \\idr{namespace} definition that is now out of scope.)\n\nWhat sort of thing is \\idr{List} itself? One good way to think about it is that\n\\idr{List} is a _function_ from \\idr{Type}s to inductive definitions; or, to put\nit another way, \\idr{List} is a function from \\idr{Type}s to \\idr{Type}s. For\nany particular type \\idr{x}, the type \\idr{List x} is an inductively defined set\nof lists whose elements are of type \\idr{x}.\n\nWith this definition, when we use the constructors \\idr{Nil} and \\idr{Cons} to\nbuild lists, we need to tell Idris the type of the elements in the lists we are\nbuilding -- that is, \\idr{Nil} and \\idr{Cons} are now _polymorphic\nconstructors_. Observe the types of these constructors:\n\n```idris\nλΠ> :t Nil\nPrelude.List.Nil : List elem\nλΠ> :t (::)\nPrelude.List.(::) : elem -> List elem -> List elem\n```\n\n\\todo[inline]{How to edit these 3 paragraphs? Implicits are defined later in\nthis chapter, and Idris doesn't require type parameters to constructors}\n\n(Side note on notation: In .v files, the \"forall\" quantifier is spelled out in\nletters. In the generated HTML files and in the way various IDEs show .v files\n(with certain settings of their display controls), ∀ is usually typeset as the\nusual mathematical \"upside down A,\" but you'll still see the spelled-out\n\"forall\" in a few places. This is just a quirk of typesetting: there is no\ndifference in meaning.)\n\nThe \"∀ X\" in these types can be read as an additional argument to the\nconstructors that determines the expected types of the arguments that follow.\nWhen \\idr{Nil} and \\idr{Cons} are used, these arguments are supplied in the same\nway as the others. For example, the list containing \\idr{2} and \\idr{1} is\nwritten like this:\n\nCheck (cons nat 2 (cons nat 1 (nil nat))).\n\n(We've written \\idr{Nil} and \\idr{Cons} explicitly here because we haven't yet\ndefined the \\idr{[]} and \\idr{::} notations for the new version of lists. We'll\ndo that in a bit.)\n\nWe can now go back and make polymorphic versions of all the list-processing\nfunctions that we wrote before. Here is \\idr{repeat}, for example:\n\n> repeat : (x_ty : Type) -> (x : x_ty) -> (count : Nat) -> List x_ty\n> repeat x_ty x Z = Nil\n> repeat x_ty x (S count') = x :: repeat x_ty x count'\n\nAs with \\idr{Nil} and \\idr{Cons}, we can use \\idr{repeat} by applying it first\nto a type and then to its list argument:\n\n> test_repeat1 : repeat Nat 4 2 = 4 :: (4 :: Nil)\n> test_repeat1 = Refl\n\nTo use \\idr{repeat} to build other kinds of lists, we simply instantiate it with\nan appropriate type parameter:\n\n> test_repeat2 : repeat Bool False 1 = False :: Nil\n> test_repeat2 = Refl\n\n\n==== Exercise: 2 stars (mumble_grumble)\n\n\\ \\todo[inline]{Explain implicits and \\idr{{x=foo}} syntax first? Move after the\n\"Supplying Type Arguments Explicitly\" section?}\n\n> namespace MumbleGrumble\n\nConsider the following two inductively defined types.\n\n> data Mumble : Type where\n> A : Mumble\n> B : Mumble -> Nat -> Mumble\n> C : Mumble\n\n> data Grumble : (x : Type) -> Type where\n> D : Mumble -> Grumble x\n> E : x -> Grumble x\n\nWhich of the following are well-typed elements of \\idr{Grumble x} for some type\n\\idr{x}?\n\n - \\idr{D (B A 5)}\n - \\idr{D (B A 5) {x=Mumble}}\n - \\idr{D (B A 5) {x=Bool}}\n - \\idr{E True {x=Bool}}\n - \\idr{E (B C 0) {x=Mumble}}\n - \\idr{E (B C 0) {x=Bool}}\n - \\idr{C}\n\n> -- FILL IN HERE\n\n$\\square$\n\n\\todo[inline]{Merge 3 following sections into one about Idris implicits? Mention\nthe lowercase/uppercase distinction.}\n\n\n==== Type Annotation Inference\n\n\\todo[inline]{This has already happened earlier at \\idr{repeat}, delete most of\nthis?}\n\nLet's write the definition of \\idr{repeat} again, but this time we won't specify\nthe types of any of the arguments. Will Idris still accept it?\n\nFixpoint repeat' X x count : list X :=\n match count with | 0 ⇒ nil X | S count' ⇒ cons X x (repeat' X x count') end.\n\nIndeed it will. Let's see what type Idris has assigned to \\idr{repeat'}:\n\nCheck repeat'. (* ===> forall X : Type, X -> nat -> list X *) Check repeat. (*\n===> forall X : Type, X -> nat -> list X *)\n\nIt has exactly the same type type as \\idr{repeat}. Idris was able to use _type\ninference_ to deduce what the types of \\idr{X}, \\idr{x}, and \\idr{count} must\nbe, based on how they are used. For example, since \\idr{X} is used as an\nargument to \\idr{Cons}, it must be a \\idr{Type}, since \\idr{Cons} expects a\n\\idr{Type} as its first argument; matching \\idr{count} with \\idr{Z} and \\idr{S}\nmeans it must be a \\idr{Nat}; and so on.\n\nThis powerful facility means we don't always have to write explicit type\nannotations everywhere, although explicit type annotations are still quite\nuseful as documentation and sanity checks, so we will continue to use them most\nof the time. You should try to find a balance in your own code between too many\ntype annotations (which can clutter and distract) and too few (which forces\nreaders to perform type inference in their heads in order to understand your\ncode).\n\n\n==== Type Argument Synthesis\n\n\\todo[inline]{We should mention the \\idr{_} parameters but it won't work like\nthis in Idris}\n\nTo use a polymorphic function, we need to pass it one or more types in addition\nto its other arguments. For example, the recursive call in the body of the\n\\idr{repeat} function above must pass along the type \\idr{x_ty}. But since the\nsecond argument to \\idr{repeat} is an element of \\idr{x_ty}, it seems entirely\nobvious that the first argument can only be \\idr{x_ty} — why should we have to\nwrite it explicitly?\n\nFortunately, Idris permits us to avoid this kind of redundancy. In place of any\ntype argument we can write the \"implicit argument\" \\idr{_}, which can be read as\n\"Please try to figure out for yourself what belongs here.\" More precisely, when\nIdris encounters a \\idr{_}, it will attempt to _unify_ all locally available\ninformation -- the type of the function being applied, the types of the other\narguments, and the type expected by the context in which the application appears\n-- to determine what concrete type should replace the \\idr{_}.\n\nThis may sound similar to type annotation inference -- indeed, the two\nprocedures rely on the same underlying mechanisms. Instead of simply omitting\nthe types of some arguments to a function, like\n\n repeat' X x count : list X :=\n\nwe can also replace the types with \\idr{_}\n\n repeat' (X : _) (x : _) (count : _) : list X :=\n\nto tell Idris to attempt to infer the missing information.\n\nUsing implicit arguments, the \\idr{count} function can be written like this:\n\nFixpoint repeat'' X x count : list X :=\n match count with | 0 ⇒ nil _ | S count' ⇒ cons _ x (repeat'' _ x count') end.\n\nIn this instance, we don't save much by writing \\idr{_} instead of \\idr{x}. But\nin many cases the difference in both keystrokes and readability is nontrivial.\nFor example, suppose we want to write down a list containing the numbers\n\\idr{1}, \\idr{2}, and \\idr{3}. Instead of writing this...\n\nDefinition list123 :=\n cons nat 1 (cons nat 2 (cons nat 3 (nil nat))).\n\n...we can use argument synthesis to write this:\n\nDefinition list123' :=\n cons _ 1 (cons _ 2 (cons _ 3 (nil _))).\n\n\n==== Implicit Arguments\n\nWe can go further and even avoid writing \\idr{_}'s in most cases by telling\nIdris _always_ to infer the type argument(s) of a given function. The Arguments\ndirective specifies the name of the function (or constructor) and then lists its\nargument names, with curly braces around any arguments to be treated as\nimplicit. (If some arguments of a definition don't have a name, as is often the\ncase for constructors, they can be marked with a wildcard pattern \\idr{_}.)\n\nArguments nil {X}. Arguments cons {X} _ _. Arguments repeat {X} x count.\n\nNow, we don't have to supply type arguments at all:\n\nDefinition list123'' := cons 1 (cons 2 (cons 3 nil)).\n\nAlternatively, we can declare an argument to be implicit when defining the\nfunction itself, by surrounding it in curly braces instead of parens. For\nexample:\n\n> repeat' : {x_ty : Type} -> (x : x_ty) -> (count : Nat) -> List x_ty\n> repeat' x Z = Nil\n> repeat' x (S count') = x :: repeat' x count'\n\n(Note that we didn't even have to provide a type argument to the recursive call\nto \\idr{repeat'}; indeed, it would be invalid to provide one!)\n\nWe will use the latter style whenever possible, but we will continue to use\nexplicit declarations in data types. The reason for this is that marking the\nparameter of an inductive type as implicit causes it to become implicit for the\ntype itself, not just for its constructors. For instance, consider the following\nalternative definition of the \\idr{List} type:\n\n> data List' : {x : Type} -> Type where\n> Nil' : List'\n> Cons' : x -> List' -> List'\n\nBecause \\idr{x} is declared as implicit for the _entire_ inductive definition\nincluding \\idr{List'} itself, we now have to write just \\idr{List'} whether we\nare talking about lists of numbers or booleans or anything else, rather than\n\\idr{List' Nat} or \\idr{List' Bool} or whatever; this is a step too far.\n\n\\todo[inline]{Added the implicit inference explanation here}\n\nThere's another step towards conciseness that we can take in Idris -- drop the\nimplicit argument completely in function definitions! Idris will automatically\ninsert them for us when it encounters unknown variables. _Note that by\nconvention this will only happen for variables starting on a lowercase letter_.\n\n> repeat'' : (x : x_ty) -> (count : Nat) -> List x_ty\n> repeat'' x Z = Nil\n> repeat'' x (S count') = x :: repeat'' x count'\n\nLet's finish by re-implementing a few other standard list functions on our new\npolymorphic lists...\n\n> app : (l1, l2 : List x) -> List x\n> app Nil l2 = l2\n> app (h::t) l2 = h :: app t l2\n\n> rev : (l : List x) -> List x\n> rev [] = []\n> rev (h::t) = app (rev t) (h::Nil)\n\n> length : (l : List x) -> Nat\n> length [] = Z\n> length (_::l') = S (length l')\n\n> test_rev1 : rev (1::2::[]) = 2::1::[]\n> test_rev1 = Refl\n\n> test_rev2 : rev (True::[]) = True::[]\n> test_rev2 = Refl\n\n> test_length1 : length (1::2::3::[]) = 3\n> test_length1 = Refl\n\n\n==== Supplying Type Arguments Explicitly\n\nOne small problem with declaring arguments implicit is that, occasionally, Idris\ndoes not have enough local information to determine a type argument; in such\ncases, we need to tell Idris that we want to give the argument explicitly just\nthis time. For example, suppose we write this:\n\n```idris\nλΠ> :let mynil = Nil\n(input):Can't infer argument elem to []\n```\n\nHere, Idris gives us an error because it doesn't know what type argument to\nsupply to \\idr{Nil}. We can help it by providing an explicit type declaration\nvia \\idr{the} function (so that Idris has more information available when it\ngets to the \"application\" of \\idr{Nil}):\n\n```idris\nλΠ> :let mynil = the (List Nat) Nil\n```\n\nAlternatively, we can force the implicit arguments to be explicit by supplying\nthem as arguments in curly braces.\n\n```idris\nλΠ> :let mynil' = Nil {elem=Nat}\n```\n\n\\todo[inline]{Describe here how to bring variables from the type into definition\nscope via implicits?}\n\n\\todo[inline]{Explain that Idris has built-in notation for lists instead?}\n\nUsing argument synthesis and implicit arguments, we can define convenient\nnotation for lists, as before. Since we have made the constructor type arguments\nimplicit, Coq will know to automatically infer these when we use the notations.\n\nNotation \"x :: y\" := (cons x y)\n (at level 60, right associativity).\nNotation \"[ ]\" := nil. Notation \"[ x ; .. ; y ]\" := (cons x .. (cons y []) ..).\nNotation \"x ++ y\" := (app x y)\n (at level 60, right associativity).\n\nNow lists can be written just the way we'd hope:\n\n> list123''' : List Nat\n> list123''' = [1, 2, 3]\n\n\n==== Exercise: 2 stars, optional (poly_exercises)\n\nHere are a few simple exercises, just like ones in the \\idr{Lists} chapter, for\npractice with polymorphism. Complete the proofs below.\n\n> app_nil_r : (l : List x) -> l ++ [] = l\n> app_nil_r l = ?app_nil_r_rhs\n\n> app_assoc : (l, m, n : List a) -> l ++ m ++ n = (l ++ m) ++ n\n> app_assoc l m n = ?app_assoc_rhs\n\n> app_length : (l1, l2 : List x) -> length (l1 ++ l2) = length l1 + length l2\n> app_length l1 l2 = ?app_length_rhs\n\n$\\square$\n\n\n==== Exercise: 2 stars, optional (more_poly_exercises)\n\nHere are some slightly more interesting ones...\n\n> rev_app_distr : (l1, l2 : List x) -> rev (l1 ++ l2) = rev l2 ++ rev l1\n> rev_app_distr l1 l2 = ?rev_app_distr_rhs\n\n> rev_involutive : (l : List x) -> rev (rev l) = l\n> rev_involutive l = ?rev_involutive_rhs\n\n$\\square$\n\n\n=== Polymorphic Pairs\n\nFollowing the same pattern, the type definition we gave in the last chapter for\npairs of numbers can be generalized to _polymorphic pairs_, often called\n_products_:\n\n> data Prod : (x, y : Type) -> Type where\n> PPair : x -> y -> Prod x y\n\nAs with lists, we make the type arguments implicit and define the familiar\nconcrete notation.\n\n\\todo[inline]This sugar cannot be marked as private and messes up things when\nimported, consider changing the notation}\n\n> syntax \"(\" [x] \",\" [y] \")\" = PPair x y\n\nWe can also use the \\idr{syntax} mechanism to define the standard notation for\nproduct _types_:\n\n> syntax [x_ty] \"*\" [y_ty] = Prod x_ty y_ty\n\n(The annotation : type_scope tells Coq that this abbreviation should only be\nused when parsing types. This avoids a clash with the multiplication symbol.)\n\nIt is easy at first to get \\idr{(x,y)} and \\idr{x_ty*y_ty} confused. Remember\nthat \\idr{(x,y)} is a value built from two other values, while \\idr{x_ty*y_ty}\nis a type built from two other types. If \\idr{x} has type \\idr{x_ty} and \\idr{y}\nhas type \\idr{y_ty}, then \\idr{(x,y)} has type \\idr{x_ty*y_ty}.\n\nThe first and second projection functions now look pretty much as they would in\nany functional programming language.\n\n> fst : (p : x*y) -> x\n> fst (x,y) = x\n\n> snd : (p : x*y) -> y\n> snd (x,y) = y\n\n\\todo[inline]{Edit}\n\nThe following function takes two lists and combines them into a list of pairs.\nIn functional languages, it is usually called \\idr{zip} (though the Coq's\nstandard library calls it \\idr{combine}).\n\n> zip : (lx : List x) -> (ly : List y) -> List (x*y)\n> zip [] _ = []\n> zip _ [] = []\n> zip (x::tx) (y::ty) = (x,y) :: zip tx ty\n\n\n==== Exercise: 1 star, optional (combine_checks)\n\nTry answering the following questions on paper and checking your answers in\nIdris:\n\n- What is the type of \\idr{zip} (i.e., what does \\idr{:t zip} print?)\n\n- What does \\idr{combine [1,2] [False,False,True,True]} print?\n\n$\\square$\n\n\n==== Exercise: 2 stars, recommended (split)\n\nThe function \\idr{split} is the right inverse of \\idr{zip}: it takes a list of\npairs and returns a pair of lists. In many functional languages, it is called\n\\idr{unzip}.\n\nFill in the definition of \\idr{split} below. Make sure it passes the given unit\ntest.\n\n> split : (l : List (x*y)) -> (List x) * (List y)\n> split l = ?split_rhs\n\n> test_split : split [(1,False),(2,False)] = ([1,2],[False,False])\n> test_split = ?test_split_rhs\n\n$\\square$\n\n\n==== Polymorphic Options\n\nOne last polymorphic type for now: _polymorphic options_, which generalize\n\\idr{NatOption} from the previous chapter:\n\n> data Option : (x : Type) -> Type where\n> Some : x -> Option x\n> None : Option x\n\nIn Idris' standard library this type is called \\idr{Maybe}, with constructors\n\\idr{Just x} and \\idr{Nothing}.\n\nWe can now rewrite the \\idr{nth_error} function so that it works with any type\nof lists.\n\n> nth_error : (l : List x) -> (n : Nat) -> Option x\n> nth_error [] n = None\n> nth_error (a::l') n = if n == 0\n> then Some a\n> else nth_error l' (pred n)\n\n> test_nth_error1 : nth_error [4,5,6,7] 0 = Some 4\n> test_nth_error1 = Refl\n\n> test_nth_error2 : nth_error [[1],[2]] 1 = Some [2]\n> test_nth_error2 = Refl\n\n> test_nth_error3 : nth_error [True] 2 = None\n> test_nth_error3 = Refl\n\n\n==== Exercise: 1 star, optional (hd_error_poly)\n\nComplete the definition of a polymorphic version of the \\idr{hd_error} function\nfrom the last chapter. Be sure that it passes the unit tests below.\n\n> hd_error : (l : List x) -> Option x\n> hd_error l = ?hd_error_rhs\n\n> test_hd_error1 : hd_error [1,2] = Some 1\n> test_hd_error1 = ?test_hd_error1_rhs\n\n> test_hd_error2 : hd_error [[1],[2]] = Some [1]\n> test_hd_error2 = ?test_hd_error2_rhs\n\n$\\square$\n\n\n== Functions as Data\n\nLike many other modern programming languages -- including all functional\nlanguages (ML, Haskell, Scheme, Scala, Clojure etc.) -- Idris treats functions\nas first-class citizens, allowing them to be passed as arguments to other\nfunctions, returned as results, stored in data structures, etc.\n\n\n=== Higher-Order Functions\n\nFunctions that manipulate other functions are often called _higher-order_\nfunctions. Here's a simple one:\n\n> doit3times : (f: x -> x) -> (n : x) -> x\n> doit3times f n = f (f (f n))\n\nThe argument \\idr{f} here is itself a function (from \\idr{x} to \\idr{x}); the\nbody of \\idr{doit3times} applies \\idr{f} three times to some value \\idr{n}.\n\n```idris\nλΠ> :t doit3times\n-- doit3times : (x -> x) -> x -> x\n```\n\n\\todo[inline]{Explain that the prefixes are needed to avoid the implicit scoping\nrule, seems that this fires up more often when passing functions as parameters\nto other functions}\n\n> test_doit3times : doit3times Numbers.minusTwo 9 = 3\n> test_doit3times = Refl\n\n> test_doit3times' : doit3times Bool.not True = False\n> test_doit3times' = Refl\n\n\n=== Filter\n\nHere is a more useful higher-order function, taking a list of \\idr{x}s and a\n_predicate_ on \\idr{x} (a function from \\idr{x} to \\idr{Bool}) and \"filtering\"\nthe list, returning a new list containing just those elements for which the\npredicate returns \\idr{True}.\n\n> filter : (test : x -> Bool) -> (l: List x) -> List x\n> filter test [] = []\n> filter test (h::t) = if test h\n> then h :: (filter test t)\n> else filter test t\n\n(This is how it's defined in Idris's stdlib, too.)\n\nFor example, if we apply \\idr{filter} to the predicate \\idr{evenb} and a list of\nnumbers \\idr{l}, it returns a list containing just the even members of \\idr{l}.\n\n> test_filter1 : filter Numbers.evenb [1,2,3,4] = [2,4]\n> test_filter1 = Refl\n\n> length_is_1 : (l : List x) -> Bool\n> length_is_1 l = length l == 1\n\n> test_filter2 : filter Poly.length_is_1\n> [ [1,2], [3], [4], [5,6,7], [], [8] ]\n> = [ [3], [4], [8] ]\n> test_filter2 = Refl\n\nWe can use \\idr{filter} to give a concise version of the \\idr{countoddmembers}\nfunction from the `Lists` chapter.\n\n> countoddmembers' : (l: List Nat) -> Nat\n> countoddmembers' l = length (filter Numbers.oddb l)\n\n> test_countoddmembers'1 : countoddmembers' [1,0,3,1,4,5] = 4\n> test_countoddmembers'1 = Refl\n\n> test_countoddmembers'2 : countoddmembers' [0,2,4] = 0\n> test_countoddmembers'2 = Refl\n\n> test_countoddmembers'3 : countoddmembers' Nil = 0\n> test_countoddmembers'3 = Refl\n\n\n=== Anonymous Functions\n\nIt is arguably a little sad, in the example just above, to be forced to define\nthe function \\idr{length_is_1} and give it a name just to be able to pass it as\nan argument to \\idr{filter}, since we will probably never use it again.\nMoreover, this is not an isolated example: when using higher-order functions, we\noften want to pass as arguments \"one-off\" functions that we will never use\nagain; having to give each of these functions a name would be tedious.\n\nFortunately, there is a better way. We can construct a function \"on the fly\"\nwithout declaring it at the top level or giving it a name.\n\n\\todo[inline]{Can't use \\idr{*} here due to the interference from our tuple\nsugar}\n\n> test_anon_fun' : doit3times (\\n => mult n n) 2 = 256\n> test_anon_fun' = Refl\n\nThe expression \\idr{\\n => mult n n} can be read as \"the function that, given a\nnumber \\idr{n}, yields \\idr{n * n}.\"\n\nHere is the \\idr{filter} example, rewritten to use an anonymous function.\n\n> test_filter2' : filter (\\l => length l == 1)\n> [ [1,2], [3], [4], [5,6,7], [], [8] ]\n> = [ [3], [4], [8] ]\n> test_filter2' = Refl\n\n\n==== Exercise: 2 stars (filter_even_gt7)\n\nUse \\idr{filter} (instead of function definition) to write an Idris function\n\\idr{filter_even_gt7} that takes a list of natural numbers as input and returns\na list of just those that are even and greater than \\idr{7}.\n\n> filter_even_gt7 : (l : List Nat) -> List Nat\n> filter_even_gt7 l = ?filter_even_gt7_rhs\n\n> test_filter_even_gt7_1 : filter_even_gt7 [1,2,6,9,10,3,12,8] = [10,12,8]\n> test_filter_even_gt7_1 = ?test_filter_even_gt7_1_rhs\n\n> test_filter_even_gt7_2 : filter_even_gt7 [5,2,6,19,129] = []\n> test_filter_even_gt7_2 = ?test_filter_even_gt7_2_rhs\n\n$\\square$\n\n\n==== Exercise: 3 stars (partition)\n\nUse \\idr{filter} to write an Idris function \\idr{partition}:\n\n> partition : (test : x -> Bool) -> (l : List x) -> (List x) * (List x)\n> partition f xs = ?partition_rhs\n\nGiven a set \\idr{x}, a test function of type \\idr{x -> Bool} and a \\idr{List x},\n\\idr{partition} should return a pair of lists. The first member of the pair is\nthe sublist of the original list containing the elements that satisfy the test,\nand the second is the sublist containing those that fail the test. The order of\nelements in the two sublists should be the same as their order in the original\nlist.\n\n> test_partition1 : partition Numbers.oddb [1,2,3,4,5] = ([1,3,5], [2,4])\n> test_partition1 = ?test_partition1_rhs\n\n> test_partition2 : partition (\\x => False) [5,9,0] = (([], [5,9,0]))\n> test_partition2 = ?test_partition2_rhs\n\n$\\square$\n\n\n=== Map\n\nAnother handy higher-order function is called \\idr{map}.\n\n> map : (f : x -> y) -> (l : List x) -> List y\n> map f [] = []\n> map f (h::t) = (f h) :: map f t\n\nIt takes a function \\idr{f} and a list \\idr{l} = \\idr{[n1, n2, n3, ...]} and\nreturns the list \\idr{[f n1, f n2, f n3,...]}, where \\idr{f} has been applied to\neach element of \\idr{l} in turn. For example:\n\n> test_map1 : map (\\x => plus 3 x) [2,0,2] = [5,3,5]\n> test_map1 = Refl\n\nThe element types of the input and output lists need not be the same, since\n\\idr{map} takes _two_ type arguments, \\idr{x} and \\idr{y}; it can thus be\napplied to a list of numbers and a function from numbers to booleans to yield a\nlist of booleans:\n\n> test_map2 : map Numbers.oddb [2,1,2,5] = [False,True,False,True]\n> test_map2 = Refl\n\nIt can even be applied to a list of numbers and a function from numbers to\n_lists_ of booleans to yield a _list of lists_ of booleans:\n\n> test_map3 : map (\\n => [evenb n, oddb n]) [2,1,2,5]\n> = [[True,False],[False,True],[True,False],[False,True]]\n> test_map3 = Refl\n\n\n==== Exercise: 3 stars (map_rev)\n\nShow that \\idr{map} and \\idr{rev} commute. You may need to define an auxiliary\nlemma.\n\n> map_rev : (f : x -> y) -> (l : List x) -> map f (rev l) = rev (map f l)\n> map_rev f l = ?map_rev_rhs\n\n$\\square$\n\n\n==== Exercise: 2 stars, recommended (flat_map)\n\nThe function \\idr{map} maps a \\idr{List x} to a \\idr{List y} using a function of\ntype \\idr{x -> y}. We can define a similar function, \\idr{flat_map}, which maps\na \\idr{List x} to a \\idr{List y} using a function \\idr{f} of type \\idr{x -> List\ny}. Your definition should work by 'flattening' the results of \\idr{f}, like so:\n\n```idris\nflat_map (\\n => [n,n+1,n+2]) [1,5,10] = [1,2,3, 5,6,7, 10,11,12]\n```\n\n> flat_map : (f : x -> List y) -> (l : List x) -> List y\n> flat_map f l = ?flat_map_rhs\n\n> test_flat_map1 : flat_map (\\n => [n,n,n]) [1,5,4] = [1,1,1, 5,5,5, 4,4,4]\n> test_flat_map1 = ?test_flat_map1_rhs\n\n$\\square$\n\nLists are not the only inductive type that we can write a \\idr{map} function\nfor. Here is the definition of \\idr{map} for the \\idr{Option} type:\n\n> option_map : (f : x -> y) -> (xo : Option x) -> Option y\n> option_map f None = None\n> option_map f (Some x) = Some (f x)\n\n\n==== Exercise: 2 stars, optional (implicit_args)\n\nThe definitions and uses of \\idr{filter} and \\idr{map} use implicit arguments in\nmany places. Add explicit type parameters where necessary and use Idris to check\nthat you've done so correctly. (This exercise is not to be turned in; it is\nprobably easiest to do it on a copy of this file that you can throw away\nafterwards.)\n\n$\\square$\n\n\n=== Fold\n\nAn even more powerful higher-order function is called \\idr{fold}. This function\nis the inspiration for the `\"reduce\"` operation that lies at the heart of\nGoogle's map/reduce distributed programming framework.\n\n> fold : (f : x -> y -> y) -> (l : List x) -> (b : y) -> y\n> fold f [] b = b\n> fold f (h::t) b = f h (fold f t b)\n\nIntuitively, the behavior of the \\idr{fold} operation is to insert a given\nbinary operator \\idr{f} between every pair of elements in a given list. For\nexample, \\idr{fold (+) [1,2,3,4]} intuitively means \\idr{1+2+3+4}. To make this\nprecise, we also need a \"starting element\" that serves as the initial second\ninput to \\idr{f}. So, for example,\n\n\\idr{fold (+) [1,2,3,4] 0}\n\nyields\n\n\\idr{1 + (2 + (3 + (4 + 0)))}\n\nSome more examples:\n\n\\todo[inline]{We go back to \\idr{andb} here because \\idr{(&&)}'s second\nparameter is lazy, with the left fold the return type is inferred to be lazy\ntoo, leading to type mismatch.}\n\n```idris\nλΠ> :t fold andb\nfold andb : List Bool -> Bool -> Bool\n```\n\n> fold_example1 : fold (*) [1,2,3,4] 1 = 24\n> fold_example1 = Refl\n\n> fold_example2 : fold Booleans.andb [True,True,False,True] True = False\n> fold_example2 = Refl\n\n> fold_example3 : fold (++) [[1],[],[2,3],[4]] [] = [1,2,3,4]\n> fold_example3 = Refl\n\n\n==== Exercise: 1 star, advanced (fold_types_different)\n\nObserve that the type of \\idr{fold} is parameterized by _two_ type variables,\n\\idr{x} and \\idr{y}, and the parameter \\idr{f} is a binary operator that takes\nan \\idr{x} and a \\idr{y} and returns a \\idr{y}. Can you think of a situation\nwhere it would be useful for \\idr{x} and \\idr{y} to be different?\n\n> -- FILL IN HERE\n\n$\\square$\n\n\n=== Functions That Construct Functions\n\nMost of the higher-order functions we have talked about so far take functions as\narguments. Let's look at some examples that involve _returning_ functions as the\nresults of other functions. To begin, here is a function that takes a value\n\\idr{x} (drawn from some type \\idr{x}) and returns a function from \\idr{Nat} to\n\\idr{x} that yields \\idr{x} whenever it is called, ignoring its \\idr{Nat}\nargument.\n\n> constfun : (x : x_ty) -> Nat -> x_ty\n> constfun x = \\k => x\n\n> ftrue : Nat -> Bool\n> ftrue = constfun True\n\n> constfun_example1 : ftrue 0 = True\n> constfun_example1 = Refl\n\n> constfun_example2 : (constfun 5) 99 = 5\n> constfun_example2 = Refl\n\nIn fact, the multiple-argument functions we have already seen are also examples\nof passing functions as data. To see why, recall the type of \\idr{plus}.\n\n```idris\nλΠ> :t plus\nPrelude.Nat.plus : Nat -> Nat -> Nat\n```\n\nEach \\idr{->} in this expression is actually a _binary_ operator on types. This\noperator is _right-associative_, so the type of \\idr{plus} is really a shorthand\nfor \\idr{Nat -> (Nat -> Nat)} -- i.e., it can be read as saying that \"\\idr{plus}\nis a one-argument function that takes a \\idr{Nat} and returns a one-argument\nfunction that takes another \\idr{Nat} and returns a \\idr{Nat}.\" In the examples\nabove, we have always applied \\idr{plus} to both of its arguments at once, but\nif we like we can supply just the first. This is called _partial application_.\n\n> plus3 : Nat -> Nat\n> plus3 = plus 3\n\n```idris\nλΠ> :t plus3\n```\n\n> test_plus3 : plus3 4 = 7\n> test_plus3 = Refl\n\n\n> test_plus3' : doit3times Poly.plus3 0 = 9\n> test_plus3' = Refl\n\n> test_plus3'' : doit3times (plus 3) 0 = 9\n> test_plus3'' = Refl\n\n\n== Additional Exercises\n\n> namespace Exercises\n\n\n==== Exercise: 2 stars (fold_length)\n\nMany common functions on lists can be implemented in terms of \\idr{fold}. For\nexample, here is an alternative definition of \\idr{length}:\n\n> fold_length : (l : List x) -> Nat\n> fold_length l = fold (\\_, n => S n) l 0\n\n> test_fold_length1 : fold_length [4,7,0] = 3\n> test_fold_length1 = Refl\n\nProve the correctness of \\idr{fold_length}.\n\n> fold_length_correct : (l : List x) -> fold_length l = length l\n> fold_length_correct l = ?fold_length_correct_rhs\n\n$\\square$\n\n\n==== Exercise: 3 stars (fold_map)\n\nWe can also define \\idr{map} in terms of fold. Finish \\idr{fold_map} below.\n\n> fold_map : (f : x -> y) -> (l : List x) -> List y\n> fold_map f l = ?fold_map_rhs\n\nWrite down a theorem \\idr{fold_map_correct} in Idris stating that \\idr{fold_map}\nis correct, and prove it.\n\n> fold_map_correct : ?fold_map_correct\n\n$\\square$\n\n\n==== Exercise: 2 stars, advanced (currying)\n\nIn Idris, a function \\idr{f: a -> b -> c} really has the type \\idr{a -> (b ->\nc)}. That is, if you give \\idr{f} a value of type \\idr{a}, it will give you\nfunction \\idr{f' : b -> c}. If you then give \\idr{f'} a value of type \\idr{b},\nit will return a value of type \\idr{c}. This allows for partial application, as\nin \\idr{plus3}. Processing a list of arguments with functions that return\nfunctions is called _currying_, in honor of the logician Haskell Curry.\n\nConversely, we can reinterpret the type \\idr{a -> b -> c} as \\idr{(a * b) -> c}.\nThis is called _uncurrying_. With an uncurried binary function, both arguments\nmust be given at once as a pair; there is no partial application.\n\nWe can define currying as follows:\n\n> prod_curry : (f : (x * y) -> z) -> (x_val : x) -> (y_val : y) -> z\n> prod_curry f x_val y_val = f (x_val, y_val)\n\nAs an exercise, define its inverse, \\idr{prod_uncurry}. Then prove the theorems\nbelow to show that the two are inverses.\n\n> prod_uncurry : (f : x -> y -> z) -> (p : x * y) -> z\n> prod_uncurry f p = ?prod_uncurry_rhs\n\nAs a (trivial) example of the usefulness of currying, we can use it to shorten\none of the examples that we saw above:\n\n\\todo[inline]{Not sure what are they shortening here}\n\n> test_map2' : map (\\x => plus 3 x) [2,0,2] = [5,3,5]\n> test_map2' = Refl\n\n\\todo[inline]{Didn't we just write out these types explicitly?}\n\nThought exercise: before running the following commands, can you calculate the\ntypes of \\idr{prod_curry} and \\idr{prod_uncurry}?\n\n```idris\nλΠ> :t prod_curry\nλΠ> :t prod_uncurry\n```\n\n> uncurry_curry : (f : x -> y -> z) -> (x_val : x) -> (y_val : y) ->\n> prod_curry (prod_uncurry f) x_val y_val = f x_val y_val\n> uncurry_curry f x_val y_val = ?uncurry_curry_rhs\n\n> curry_uncurry : (f : (x * y) -> z) -> (p : x * y) ->\n> prod_uncurry (prod_curry f) p = f p\n> curry_uncurry f p = ?curry_uncurry_rhs\n\n$\\square$\n\n\n==== Exercise: 2 stars, advanced (nth_error_informal)\n\nRecall the definition of the \\idr{nth_error} function:\n\n```idris\n nth_error : (l : List x) -> (n : Nat) -> Option x\n nth_error [] n = None\n nth_error (a::l') n = if n == 0\n then Some a\n else nth_error l' (pred n)\n```\n\nWrite an informal proof of the following theorem:\n\n\\idr{n -> l -> length l = n -> nth_error l n = None}\n\n> -- FILL IN HERE\n\n$\\square$\n\n\n==== Exercise: 4 stars, advanced (church_numerals)\n\nThis exercise explores an alternative way of defining natural numbers, using the\nso-called _Church numerals_, named after mathematician Alonzo Church. We can\nrepresent a natural number \\idr{n} as a function that takes a function \\idr{f}\nas a parameter and returns \\idr{f} iterated \\idr{n} times.\n\n> namespace Church\n\n> Nat' : {x : Type} -> Type\n> Nat' {x} = (x -> x) -> x -> x\n\nLet's see how to write some numbers with this notation. Iterating a function\nonce should be the same as just applying it. Thus:\n\n> one : Nat'\n> one f x = f x\n\nSimilarly, \\idr{two} should apply \\idr{f} twice to its argument:\n\n> two : Nat'\n> two f x = f (f x)\n\nDefining \\idr{zero} is somewhat trickier: how can we \"apply a function zero\ntimes\"? The answer is actually simple: just return the argument untouched.\n\n> zero : Nat'\n> zero f x = x\n\nMore generally, a number \\idr{n} can be written as \\idr{\\f, x => f (f ... (f x)\n...)}, with \\idr{n} occurrences of \\idr{f}. Notice in particular how the\n\\idr{doit3times} function we've defined previously is actually just the Church\nrepresentation of \\idr{3}.\n\n> three : Nat'\n> three = doit3times\n\nComplete the definitions of the following functions. Make sure that the\ncorresponding unit tests pass by proving them with \\idr{Refl}.\n\nSuccessor of a natural number:\n\n> succ' : (n : Nat' {x}) -> Nat' {x}\n> succ' n = ?succ__rhs\n\n\\todo[inline]{Even if you add \\idr{f x} on both sides of \\idr{=}, these \"unit\ntests\" don't seem to work neither with \\idr{Refl} nor with more advanced\ntechniques currently}\n\n> succ'_1 : succ' zero = one\n> succ'_1 = ?succ__1_rhs\n\n> succ'_2 : succ' one = two\n> succ'_2 = ?succ__2_rhs\n\n> succ'_3 : succ' two = three\n> succ'_3 = ?succ__3_rhs\n\nAddition of two natural numbers:\n\n> plus' : (n, m : Nat' {x}) -> Nat' {x}\n> plus' n m = ?plus__rhs\n\n> plus'_1 : plus' zero one = one\n> plus'_1 = ?plus__1_rhs\n\n> plus'_2 : plus' two three = plus' three two\n> plus'_2 = ?plus__2_rhs\n\n> plus'_3 : plus' (plus' two two) three = plus' one (plus' three three)\n> plus'_3 = ?plus__3_rhs\n\nMultiplication:\n\n> mult' : (n, m : Nat' {x}) -> Nat' {x}\n> mult' n m = ?mult__rhs\n\n> mult'_1 : mult' one one = one\n> mult'_1 = ?mult__1_rhs\n\n> mult'_2 : mult' zero (plus' three three) = zero\n> mult'_2 = ?mult__2_rhs\n\n> mult'_3 : mult' two three = plus' three three\n> mult'_3 = ?mult__3_rhs\n\nExponentiation:\n\n\\todo[inline]{Edit the hint. Can't make it work with \\idr{exp' : (n, m : Nat'\n{x}) -> Nat' {x}}.}\n\n(Hint: Polymorphism plays a crucial role here. However, choosing the right type\nto iterate over can be tricky. If you hit a \"Universe inconsistency\" error, try\niterating over a different type: \\idr{Nat'} itself is usually problematic.)\n\n> exp' : (n : Nat' {x}) -> (m : Nat' {x=x->x}) -> Nat' {x}\n> exp' n m = ?exp__rhs\n\n\\todo[inline]{This won't typecheck under this signature of \\idr{exp} because of\n2 instances of \\idr{two}}\n\n> -- exp'_1 : exp' two two = plus' two two\n> -- exp'_1 = ?exp__1_rhs\n\n> exp'_2 : exp' three two = plus' (mult' two (mult' two two)) one\n> exp'_2 = ?exp__2_rhs\n\n> exp'_3 : exp' three zero = one\n> exp'_3 = ?exp__3_rhs\n\n$\\square$\n", "meta": {"hexsha": "08ed74d5160f8ac93bf62c9c3a08c90f10cb073e", "size": 36224, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "src/Poly.lidr", "max_stars_repo_name": "MarcelineVQ/software-foundations", "max_stars_repo_head_hexsha": "41b6038e7e3a007ca57f42b50794775633e1c5bd", "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/Poly.lidr", "max_issues_repo_name": "MarcelineVQ/software-foundations", "max_issues_repo_head_hexsha": "41b6038e7e3a007ca57f42b50794775633e1c5bd", "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/Poly.lidr", "max_forks_repo_name": "MarcelineVQ/software-foundations", "max_forks_repo_head_hexsha": "41b6038e7e3a007ca57f42b50794775633e1c5bd", "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.1418115279, "max_line_length": 80, "alphanum_fraction": 0.6896808746, "num_tokens": 10950, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7401743620390162, "lm_q2_score": 0.8006920092299293, "lm_q1q2_score": 0.592651697121501}}
{"text": "module Part2.Sec5_3_3_dpair\nimport Data.Vect\n\n{-\nNote, Idris figures out Vect size. \nIn Haskell \"_\" == \"I do not care\" \nIn Idris \"_\" == \"You figure it out\"\n-}\n||| Conversion between a list and dependent pair\n||| Think about using strong dependent types in runtime calculations.\nlistToVect : List a -> (n ** Vect n a)\nlistToVect [] = (_ ** [])\nlistToVect (x :: xs) = \n let (_ ** vxs) = listToVect xs\n in (_ ** x :: vxs)\n", "meta": {"hexsha": "3f89c4b036ab321adb606fc0531085de90392ec0", "size": 435, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Part2/Sec5_3_3_dpair.idr", "max_stars_repo_name": "rpeszek/IdrisTddNotes", "max_stars_repo_head_hexsha": "37bca29819315be6f4001d0fe42ae101116fc06d", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 40, "max_stars_repo_stars_event_min_datetime": "2018-06-07T06:18:02.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-24T06:08:35.000Z", "max_issues_repo_path": "src/Part2/Sec5_3_3_dpair.idr", "max_issues_repo_name": "rpeszek/IdrisTddNotes", "max_issues_repo_head_hexsha": "37bca29819315be6f4001d0fe42ae101116fc06d", "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/Part2/Sec5_3_3_dpair.idr", "max_forks_repo_name": "rpeszek/IdrisTddNotes", "max_forks_repo_head_hexsha": "37bca29819315be6f4001d0fe42ae101116fc06d", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2018-07-08T18:55:19.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-22T09:25:43.000Z", "avg_line_length": 27.1875, "max_line_length": 69, "alphanum_fraction": 0.6298850575, "num_tokens": 132, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7520125848754472, "lm_q2_score": 0.7879311981328135, "lm_q1q2_score": 0.5925341770118653}}
{"text": "module Types.Finite\n\nimport Data.Fin\nimport Control.Isomorphism\n\n\n%default total\n\nto : Iso a b -> a -> b\nto (MkIso to from toFrom fromTo) = to\n\nfrom : Iso a b -> b -> a\nfrom (MkIso to from toFrom fromTo) = from\n\nclass Finite a (n : Nat) where\n total\n isFinite : Iso a (Fin n)\n\ntotal\ntoFin : Finite a n => a -> Fin n\ntoFin = to isFinite\n\n\ntotal\nfromFin : Finite a n => Fin n -> a\nfromFin = from isFinite\n\n\ninstance Finite () 1 where\n isFinite = MkIso to from ok1 ok2\n where to : () -> Fin 1\n to () = FZ\n from : Fin 1 -> ()\n from FZ = ()\n from (FS f) = absurd f\n ok2 : (x : ()) -> from (to x) = x\n ok2 () = Refl\n ok1 : (x : Fin 1) -> to (from x) = x\n ok1 FZ = Refl\n ok1 (FS f) = absurd f\n\ninstance Finite Bool 2 where\n isFinite = MkIso to from ok1 ok2\n where to : Bool -> Fin 2\n to False = 0\n to True = 1\n from : Fin 2 -> Bool\n from FZ = False\n from (FS FZ) = True\n from (FS (FS x)) = absurd x \n ok1 : (f : Fin 2) -> to (from f) = f\n ok1 FZ = Refl\n ok1 (FS FZ) = Refl\n ok1 (FS (FS x)) = absurd x \n ok2 : (b : Bool) -> from (to b) = b\n ok2 False = Refl\n ok2 True = Refl\n\n-- Isomorphisms over Maybe\nmaybeVoidUnit2 : Iso (Maybe Void) ()\nmaybeVoidUnit2 = MkIso to from iso1 iso2\n where to : Maybe Void -> ()\n to Nothing = ()\n to (Just x) = absurd x\n from : () -> Maybe Void\n from () = Nothing\n iso1 : (x : ()) -> to (from x) = x\n iso1 () = Refl\n iso2 : (y : Maybe Void) -> from (to y) = y\n iso2 Nothing = Refl\n iso2 (Just x) = absurd x\n\n", "meta": {"hexsha": "884d2a1859d4e8b84d30f95a136f1d5987cc4d67", "size": 1712, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Types/Finite.idr", "max_stars_repo_name": "david-christiansen/idris-utils", "max_stars_repo_head_hexsha": "f828b9fbc5b2df754eebfbfcb1b2ead86f16352f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2016-10-07T06:22:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T21:15:29.000Z", "max_issues_repo_path": "Types/Finite.idr", "max_issues_repo_name": "david-christiansen/idris-utils", "max_issues_repo_head_hexsha": "f828b9fbc5b2df754eebfbfcb1b2ead86f16352f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-01-30T23:21:51.000Z", "max_issues_repo_issues_event_max_datetime": "2015-01-31T19:05:05.000Z", "max_forks_repo_path": "Types/Finite.idr", "max_forks_repo_name": "david-christiansen/idris-utils", "max_forks_repo_head_hexsha": "f828b9fbc5b2df754eebfbfcb1b2ead86f16352f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-01-30T17:59:38.000Z", "max_forks_repo_forks_event_max_datetime": "2015-01-30T17:59:38.000Z", "avg_line_length": 23.4520547945, "max_line_length": 50, "alphanum_fraction": 0.4964953271, "num_tokens": 567, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916099737806, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.5922429987771005}}
{"text": "module ALaCarte\n\nimport Fix\n\n%access public export\n\n||| Position of a sub-type in a super-type composed of signatures `fs`.\ndata Sig : (fs : List (Type -> Type)) -> (a : Type) -> Type where\n ||| The sub-type `f` is located at the head of the list of composed types `fs`.\n Here : f a -> Sig (f :: fs) a\n ||| The sub-type is located after the head of the list.\n There : Sig fs a -> Sig (f :: fs) a\n\n||| A proof that some signature `f` is found in a list `fs`.\ndata Elem : (f : Type -> Type) -> (fs : List (Type -> Type)) -> Type where\n ||| A proof the signature `f` is at the head of the list of signatures `fs`.\n H : Elem f (f :: fs)\n ||| A proof the signature `f` is after the front of the list.\n T : Elem f ys -> Elem f (y :: ys)\n\n||| Inject some sub-type `f a` into a super type, `Sig fs a`, containing syntax\n||| for `f a`, i.e. `Elem f fs`.\ninj : {auto prf : Elem f fs} -> f a -> Sig fs a\ninj {prf=H} x = Here x\ninj {prf=T t} x = There (inj {prf=t} x)\n\n||| Inject some type `f a` into a `Fix` tree containing syntax for `f a`.\ninject : {auto prf : Elem f fs} -> f (Fix (Sig fs)) -> Fix (Sig fs)\ninject = In . inj\n\n||| Base case making `Sig` an instance of `Functor`.\nFunctor (Sig []) where\n map _ (Here _) impossible\n map _ (There _) impossible\n\n||| Recursive case making `Sig` an instance of `Functor`.\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\n||| Algebra used to fold over a `Fix` tree, creating a value of type `a`.\ninterface Alg (f : Type -> Type) (a : Type) where\n alg : f a -> a\n\n||| Base case making `Sig` an instance of `Alg`.\nAlg (Sig []) a where\n alg (Here _) impossible\n alg (There _) impossible\n\n||| Recusrive case making `Sig` an instance of `Alg`.\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\n||| Convenience method for folding over a `Fix` tree using the algebra defined\n||| in interface instances.\neval : (Functor f, Alg f a) => Fix f -> a\neval = cata alg\n", "meta": {"hexsha": "568d709f74b0aec4944871b9a4d6cdf852ab80b7", "size": 2091, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/ALaCarte.idr", "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/ALaCarte.idr", "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/ALaCarte.idr", "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": 35.4406779661, "max_line_length": 83, "alphanum_fraction": 0.6087996174, "num_tokens": 660, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.867035752930664, "lm_q2_score": 0.6825737344123242, "lm_q1q2_score": 0.5918158317468846}}
{"text": "ap : (a -> b -> c) -> (a -> b) -> a -> c\nap f g x = f x (g x)\n\n-- the one with Lazy Bool was making type checking tricky\n||| A strict version of the && operator\nand : Bool -> Bool -> Bool\nand False _ = False\nand True x = x\n\nisPalindrome : String -> Bool\nisPalindrome = ap (==) reverse\n\nisPalindromeIgnoringCase : String -> Bool\nisPalindromeIgnoringCase = (ap (==) reverse) . toLower\n\n-- Maybe I should just give up with this point free thing\n-- but it's way too fun to stop\nisBigPalindrome : String -> Bool\nisBigPalindrome =\n ap (and . ((> 10) . length)) ((ap (==) reverse) . toLower)\n\n-- Ok I give up\nisPalindromeOfSize : Nat -> String -> Bool\nisPalindromeOfSize n str =\n str == (reverse str) && length str > n\n\ncounts : String -> (Nat, Nat)\ncounts str = ((length . words) str, length str)\n\ntopTen : Ord a => List a -> List a\ntopTen = List.take 10 . reverse . sort \n\noverLen : Nat -> List String -> Nat\noverLen n = length . filter ((> n) . length)\n\nmain : IO ()\nmain = repl \"\\n>> \" (show . isBigPalindrome)\n", "meta": {"hexsha": "cb466451f39f71c716b34d436bd7ffbaf4b680b1", "size": 1010, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "palindrome.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": "palindrome.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": "palindrome.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": 26.5789473684, "max_line_length": 60, "alphanum_fraction": 0.6386138614, "num_tokens": 296, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7718434978390746, "lm_q2_score": 0.7662936377487304, "lm_q1q2_score": 0.5914587617318088}}
{"text": "\nmodule Progress\n\n-- Pseudo-progress theorem for the 'Step' relation\n-- in the untyped lambda calculus.\n\n\nimport Step\nimport Subst\nimport Term\n\n\n%access export\n\n\n-------------------------\n-- Begin: PSEUDO-PROGRESS\n\n-- Function 'progress' looks like the usual progress theorem\n-- but notice that 'progress' is not a total function.\n--\n-- (It is therefore not consistent to interpret the\n-- definition of the function 'progress' as a proof.)\n--\nprogress : (e : Term 0) -> Either (Value e) (e' : Term 0 ** (Step e e'))\n-- Expressions that are variables cannot occur in an empty context:\n-- (In other words, variables are not closed expressions.)\nprogress (TVar i) = absurd $ FinZAbsurd i\n-- Abstractions are values already:\nprogress (TAbs _) = Left VAbs\n-- Applications can reduce in three different ways, the most\n-- interesting of which occurs when both arguments of 'App'\n-- are values already: in this case, the function 'subst'\n-- is required:\nprogress (TApp e1 e2) = case progress e1 of\n Right (e' ** st) => Right (TApp e' e2 ** StApp1 st)\n Left v1 => \n case progress e2 of\n Right (e' ** st) => Right (TApp e1 e' ** StApp2 v1 st)\n Left v2 => case e1 of\n TAbs f => let e'' = subst e2 FZ f\n in Right (e'' ** StBeta v2)\n-- The constant 'Zero' is a value already:\nprogress TZero = Left VZero\n--\nprogress (TSucc e) = case progress e of\n Right (e' ** st) => Right (TSucc e' ** StSucc st)\n Left v => Left (VSucc v)\nprogress (TPred e) = case progress e of\n Right (e' ** st) => Right (TPred e' ** StPred st)\n Left v => \n case e of\n TZero => Right (TZero ** StPredZero)\n TSucc e' => case v of \n VAbs impossible\n VZero impossible\n VSucc v' => Right (e' ** StPredSucc v')\n-- \nprogress (TIfz e1 e2 e3) = case progress e1 of\n Right (e' ** st) => Right $ (TIfz e' e2 e3 ** StIfz st)\n Left v => case v of\n VZero => Right (e2 ** StIfzZero)\n VSucc v' => Right (e3 ** StIfzSucc v')\n\n-- End: PSEUDO-PROGRESS\n-----------------------\n\n", "meta": {"hexsha": "b20ab7bf21f5e4ba6c36faca49c5310e2cb1bc21", "size": 2228, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "untyped/src/Progress.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": "untyped/src/Progress.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": "untyped/src/Progress.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": 32.7647058824, "max_line_length": 72, "alphanum_fraction": 0.5596947935, "num_tokens": 610, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8539127455162773, "lm_q2_score": 0.6926419704455589, "lm_q1q2_score": 0.5914558066429714}}
{"text": "import Data.Vect\n\n{- 5 -}\n\nsumEntries : Num a => (pos : Integer) -> Vect n a -> Vect n a -> Maybe a\nsumEntries {n} pos xs ys = case integerToFin pos n of\n Nothing => Nothing\n Just idx => Just (index idx xs + index idx ys)\n", "meta": {"hexsha": "0b13b4a44666f94f0d4c259355be7b5952042b73", "size": 284, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Chapter4/Exercises/ex_4_2_5.idr", "max_stars_repo_name": "PiotrJander/TypeDD-Samples", "max_stars_repo_head_hexsha": "a5c08a13e6a6ec804171526aca10aae946588323", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 161, "max_stars_repo_stars_event_min_datetime": "2017-02-27T02:28:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-18T22:17:47.000Z", "max_issues_repo_path": "Chapter4/Exercises/ex_4_2_5.idr", "max_issues_repo_name": "gdevanla/TypeDD-Samples", "max_issues_repo_head_hexsha": "a5c08a13e6a6ec804171526aca10aae946588323", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2017-03-26T23:27:19.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T07:32:25.000Z", "max_forks_repo_path": "Chapter4/Exercises/ex_4_2_5.idr", "max_forks_repo_name": "gdevanla/TypeDD-Samples", "max_forks_repo_head_hexsha": "a5c08a13e6a6ec804171526aca10aae946588323", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 41, "max_forks_repo_forks_event_min_datetime": "2017-03-19T11:01:54.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-10T05:30:22.000Z", "avg_line_length": 31.5555555556, "max_line_length": 78, "alphanum_fraction": 0.5, "num_tokens": 69, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8267117855317473, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.5914494589986085}}
{"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> transposeHelper : Vect m a -> (1 xs_trans : Vect m (Vect k a)) -> Vect m (Vect (S k) a)\n", "meta": {"hexsha": "2fd84237f0e39c7a4061506e6e98a3a2908967c8", "size": 222, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/literate005/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": 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/tests/idris2/literate005/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": 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/tests/idris2/literate005/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": 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.75, "max_line_length": 89, "alphanum_fraction": 0.5135135135, "num_tokens": 78, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8418256472515683, "lm_q2_score": 0.7025300511670689, "lm_q1q2_score": 0.5914078150373951}}
{"text": "module Data.Matrix.RowEchelon\n\nimport Control.Algebra\nimport Classes.Verified\nimport Control.Algebra.VectorSpace -- definition of module\n\nimport Data.Matrix\nimport Data.Matrix.Algebraic -- module instances; from Idris 0.9.20\nimport Data.Matrix.AlgebraicVerified\n\nimport Data.Vect.Structural\nimport Data.Matrix.Structural\n\nimport Data.ZZ\nimport Control.Algebra.NumericInstances\nimport Control.Algebra.ZZVerifiedInstances\nimport Data.Matrix.ZZVerified\n\nimport Data.Matrix.ZZModuleSpan\nimport Data.Matrix.LinearCombinations\n\nimport Data.Fin.FinOrdering\nimport Data.Fin.Structural\n\n-- For style. ((Reader r a) equivalent to (r -> a))\nimport Control.Monad.Identity\nimport Control.Monad.Reader\n\nimport Control.Isomorphism\n\n%default total\n\n\n\n{-\nTable of contents:\n* ZZ proofs\n* Vect/Matrix proofs\n* The leading nonzero of a vector\n* DANRZ property\n* Corollary bispannability property\n* Row echelon properties\n-}\n\n\n\n{-\nZZ proofs\n-}\n\n\n\nzzZOrOrPosNeg : (z : ZZ) -> Either (z=Pos 0) $ Either (k : _ ** z = Pos (S k)) $ (k : _ ** z = NegS k)\nzzZOrOrPosNeg (Pos Z) = Left Refl\nzzZOrOrPosNeg (Pos (S k)) = Right (Left (k ** Refl))\nzzZOrOrPosNeg (NegS k) = Right (Right (k ** Refl))\n\n\n\n{-\nVect/Matrix proofs\n-}\n\n\n\nindicesConstColChariz : indices i FZ (map (r::) xs) = r\nindicesConstColChariz {i} {r}\n\t= trans (sym $ indexMapChariz {f=index FZ})\n\t$ trans (cong {f=index i} $ leadingElemExtensionFirstColReplicate r)\n\tindexReplicateChariz\n\nindicesConstColChariz2 : indices i (FS j) (map (r::) xs) = indices i j xs\nindicesConstColChariz2 {i} {j}\n\t= trans (sym $ indexMapChariz {f=index (FS j)})\n\t$ trans (cong {f=index i} leadingElemExtensionColFSId)\n\t$ indexMapChariz {f=index j}\n\n\n\n{-\nThe leading nonzero of a vector\n\n* (leadingNonzeroNum) Its computation\n* (leadingNonzeroProp) The leading nonzero property of a (Maybe (Fin n)) for a vector --\n\tif Nothing, the vector is 0\n\tif Just k, k is the leading nonzero of the vector\n* (leadingNonzeroProof) Proof the computation gives the leading nonzero (has the leading nonzero prop)\n-}\n\n\n\nleadingNonzeroNum : (v : Vect n ZZ) -> Maybe (Fin n)\nleadingNonzeroNum [] = Nothing\nleadingNonzeroNum {n= S predn} (Pos Z::xs) = map FS $ leadingNonzeroNum xs\nleadingNonzeroNum {n= S predn} (k::xs) = Just FZ\n\nleadingNonzeroProp : (v : Vect n ZZ) -> Maybe (Fin n) -> Type\nleadingNonzeroProp {n} v mnel =\n\tEither\n\t\t(mnel = Nothing, v = neutral)\n\t\t( nel : Fin n **\n\t\t\t(mnel = Just nel\n\t\t\t, {i : Fin n}\n\t\t\t\t-> finToNat i `LTRel` finToNat nel\n\t\t\t\t-> index i v = Pos Z\n\t\t\t, Not (index nel v = Pos Z) )\n\t\t)\n\nleadingNonzeroProof_lemmaNeutToNothing : leadingNonzeroNum Algebra.neutral = Nothing\nleadingNonzeroProof_lemmaNeutToNothing = ?leadingNonzeroProof_lemmaNeutToNothing'\n\nleadingNonzeroProof_lemmaNeutToNothing' = proof\n\tintro n\n\tinduction n\n\texact Refl\n\tintro predn\n\texact cong {f=map FS}\n\n\n\nleadingNonzeroProof : {v : Vect n ZZ} -> leadingNonzeroProp v (leadingNonzeroNum v)\nleadingNonzeroProof {v=[]} = Left (Refl, Refl)\nleadingNonzeroProof {n=S predn} {v=Pos Z::rs} with (leadingNonzeroProof {v=rs})\n\t| Left (_, pr) = rewrite pr\n\t\tin Left (cong {f=map FS} leadingNonzeroProof_lemmaNeutToNothing, Refl)\n\t| Right (nel ** (isJ, l_fn, r_pr))\n\t\t= Right (FS nel ** (cong {f=map FS} isJ, l_fn', r_pr))\n\t\twhere\n\t\t\tl_fn' : {ii : Fin (S predn)}\n\t\t\t\t-> finToNat ii `LTRel` finToNat (FS nel)\n\t\t\t\t-> index ii (Pos Z::rs) = Pos Z\n\t\t\tl_fn' {ii=FZ} _ = Refl\n\t\t\tl_fn' {ii=FS j} precondit = l_fn $ fromLteSucc precondit\nleadingNonzeroProof {n=S predn} {v=Pos (S k)::rs}\n\t= Right ( FZ **\n\t\t(Refl, void . succNotLTEzero, flip (replace {P=distinguish_Z_SZ}) ()) )\n\t\twhere\n\t\t\tdistinguish_Z_SZ : ZZ -> Type\n\t\t\tdistinguish_Z_SZ (Pos Z) = Void\n\t\t\tdistinguish_Z_SZ z = ()\nleadingNonzeroProof {n=S predn} {v=NegS k::rs}\n\t= Right ( FZ **\n\t\t(Refl, void . succNotLTEzero, flip (replace {P=distinguish_Z_SZ}) ()) )\n\t\twhere\n\t\t\tdistinguish_Z_SZ : ZZ -> Type\n\t\t\tdistinguish_Z_SZ (Pos Z) = Void\n\t\t\tdistinguish_Z_SZ z = ()\n\n\n\n{-\nlemma1 : leadingNonzeroNum rs = Nothing -> leadingNonzeroNum (Pos Z :: rs) = Nothing\nlemma1 = ?lemma1'\n\nlemma1_mat : leadingNonzeroNum (index nel xs) = Nothing\n\t-> leadingNonzeroNum (index (FS nel) $ map ((Pos Z)::) xs) = Nothing\n\nlemma2 : leadingNonzeroNum rs = Nothing -> rs = Algebra.neutral\nlemma2 = ?lemma2'\n\nlemma3 : leadingNonzeroNum rs = Just mel\n\t-> leadingNonzeroNum (Pos Z :: rs) = Just (FS mel)\n\nlemma3_mat : leadingNonzeroNum (index nel xs) = Just mel\n\t-> leadingNonzeroNum (index (FS nel) $ map ((Pos Z)::) xs) = Just (FS mel)\n-}\n\n||| (x::xs) leads with a nonzero for x not 0\nleadingNonzeroIsFZIfNonzero :\n\tNot (index FZ x = Pos Z)\n\t-> leadingNonzeroNum x = Just FZ\nleadingNonzeroIsFZIfNonzero {x=x::xs} nonz with ( runIso eitherBotRight $ map nonz $ mirror $ zzZOrOrPosNeg x )\n\t| Left (k ** prposS) = rewrite prposS in Refl\n\t| Right (k ** prnegS) = rewrite prnegS in Refl\n\n\n\n{-\nDANRZ property:\nThat every entry (<= horiz, > vert) below and not to the right of this one is 0.\n-}\n\n\n\ndownAndNotRightOfEntryImpliesZ : (xs : Matrix n m ZZ) -> (row : Fin n) -> (col : Fin m) -> Type\ndownAndNotRightOfEntryImpliesZ xs nel mel {n} {m} = (i : Fin n) -> (j : Fin m) -> (finToNat nel `LTRel` finToNat i) -> (finToNat j `LTERel` finToNat mel) -> indices i j xs = Pos Z\n{-\nEquivalent properties:\n1) map (take mel) (drop nel xs) = neutral\n2) (nel `LT` i) -> (j `LTE` mel) -> indices i j xs = Pos Z\n\t# In pseudocode, because we decided not to use direct LT and LTE of Fins.\n\n---\n\nWe cannot write\n\n> downAndNotRightOfEntryImpliesZ : (xs : Matrix n m ZZ) -> (row : Fin n) -> (col : Fin m) -> Type\n> downAndNotRightOfEntryImpliesZ xs nel mel {n} {m} = {i : Fin n} -> {j : Fin m} -> (finToNat nel `LTRel` finToNat i) -> (finToNat j `LTERel` finToNat mel) -> indices i j xs = Pos Z\n\nbecause the error described in ImplicitArgsError applied to (i) and (j) in ({i : Fin n} -> {j : Fin m} -> ...).\n-}\n\n\n\nweakenDownAndNotRight :\n\tdownAndNotRightOfEntryImpliesZ mat (FS prednel) mel\n\t-> ((j : _)\n\t\t-> LTERel (finToNat j) (finToNat mel)\n\t\t-> indices (FS prednel) j mat = Pos Z)\n\t-> downAndNotRightOfEntryImpliesZ mat (weaken prednel) mel\nweakenDownAndNotRight {prednel} {mat} danrz newzfn i j iDown jNotRight\n\t= either\n\t\t(\\b => danrz i j b jNotRight)\n\t\t(\\pr => trans (cong {f=\\e => indices e j mat} pr) $ newzfn j jNotRight)\n\t$ partitionNatWknLT prednel i iDown\n\n||| A special case of (weakenDownAndNotRight).\nweakenDownAndNotRightFZ :\n\tdownAndNotRightOfEntryImpliesZ mat (FS prednel) FZ\n\t-> indices (FS prednel) FZ mat = Pos Z\n\t-> downAndNotRightOfEntryImpliesZ mat (weaken prednel) FZ\nweakenDownAndNotRightFZ {prednel} {mat} danrz newz i FZ iDown fzNotRight\n\t= either\n\t\t(\\b => danrz i FZ b fzNotRight)\n\t\t(\\pr => trans (cong {f=\\e => indices e FZ mat} pr) newz)\n\t$ partitionNatWknLT prednel i iDown\nweakenDownAndNotRightFZ _ _ _ (FS prel) _ fzNotRight\n\t= void . succNotLTEzero . lteRelToLTE $ fzNotRight\n\n\n\ntotal\nafterUpdateAtCurStillDownAndNotRight :\n\t(downAndNotRightOfEntryImpliesZ mat (FS prednel) mel)\n\t-> (downAndNotRightOfEntryImpliesZ (updateAt (FS prednel) f mat) (FS prednel) mel)\nafterUpdateAtCurStillDownAndNotRight {prednel=FZ} {mat=x::y::xs} {mel} danrz FZ j iDown jNotRight = void $ succNotLTEzero $ iDown\nafterUpdateAtCurStillDownAndNotRight {prednel=FZ} {mat=x::y::xs} {mel} danrz (FS FZ) j iDown jNotRight = void $ succNotLTEzero $ fromLteSucc iDown\nafterUpdateAtCurStillDownAndNotRight {prednel=FZ} {mat=x::y::xs} {mel} danrz (FS $ FS i) j iDown jNotRight = danrz (FS $ FS i) j iDown jNotRight\nafterUpdateAtCurStillDownAndNotRight {prednel=FS predednel} {mat=x::xs} {f} danrz FZ j iDown jNotRight = danrz FZ j iDown jNotRight\nafterUpdateAtCurStillDownAndNotRight {prednel=FS predednel} {mat=x::xs} {mel} {f} danrz (FS i) j iDown jNotRight = afterUpdateAtCurStillDownAndNotRight {prednel=predednel} {mat=xs} {mel=mel} {f=f} (\\i_xs => \\j_xs => \\iDown_xs => \\jNotRight_xs => danrz (FS i_xs) j_xs (LTESucc iDown_xs) jNotRight_xs) i j (fromLteSucc iDown) jNotRight\n\n\n\n{-\nSubsection proving (danrzLeadingZeroAlt)\n-}\n\n{-\nProved by noting\n\tgetCol FZ xs = map (index FZ) xs\nand\n\t\\j => danrz j FZ ?lt ?lte :\n\t\t(j : Fin _) -> index FZ $ index j xs = Pos 0\nbecomes by (trans (indexMapChariz {f=index FZ})) a\n\t(j : Fin _) -> index j $ map (index FZ) xs = Pos 0.\n\nSo that it suffices to prove\n\t((i : Fin _) -> index i xs = index i ys)\n\t-> xs = ys.\n-}\ndanrzTailHasLeadingZeros :\n\tdownAndNotRightOfEntryImpliesZ (x::xs) FZ FZ\n\t-> getCol FZ xs = Algebra.neutral\ndanrzTailHasLeadingZeros danrz = vecIndexwiseEq\n\t(\\j => trans (indexMapChariz {f=index FZ})\n\t\t$ trans (danrz (FS j) FZ (zLtSuccIsTrue $ finToNat j) $ Right Refl)\n\t$ sym $ indexNeutralIsNeutral1D j)\n\n-- Corrollary : decEq w/ eitherBotRight lets you extract rowEchelon proofs.\n-- In particular,\n||| x|xs\n||| 0|_\n||| 0|_\n||| ...\n||| has 0th-col 0 or its 0th row leads with a nonzero\ndanrzLeadingZeroAlt :\n\tdownAndNotRightOfEntryImpliesZ (x::xs) FZ FZ\n\t-> Either\n\t\t(getCol FZ (x::xs) = Algebra.neutral)\n\t\t(leadingNonzeroNum x = Just FZ)\ndanrzLeadingZeroAlt {x} {xs} danrz with ( decEq (index FZ x) $ Pos Z )\n\t| Yes preq = Left (vecHeadtailsEq preq $ danrzTailHasLeadingZeros danrz)\n\t| No prneq = Right $ leadingNonzeroIsFZIfNonzero prneq\n\n\n\ndanrzLastcolImpliesAllcol : {mat : Matrix (S _) (S mu) ZZ}\n\t-> downAndNotRightOfEntryImpliesZ mat FZ (last {n=mu})\n\t-> downAndNotRightOfEntryImpliesZ mat FZ mel\ndanrzLastcolImpliesAllcol danrzlast i j ltrel _ = danrzlast i j ltrel $ ltenatLastIsTrue2 j\n\ndanrzLastcolImpliesTailNeutral : {xs : Matrix n (S mu) ZZ}\n\t-> downAndNotRightOfEntryImpliesZ (x::xs) FZ (last {n=mu})\n\t-> xs=Algebra.neutral\ndanrzLastcolImpliesTailNeutral {x} {xs} {n} {mu} danrz\n\t= uniformValImpliesReplicate (replicate (S mu) $ Pos 0) xs\n\t$ \\na => uniformValImpliesReplicate (Pos 0) (index na xs) (fn na)\n\twhere\n\t\tfn : (prednel : Fin n) -> (j : Fin (S mu)) -> indices prednel j xs = Pos 0\n\t\tfn prednel j = danrz (FS prednel) j\n\t\t\t(zLtSuccIsTrue $ finToNat prednel)\n\t\t\t(ltenatLastIsTrue2 j)\n\n\n\n{-\nCorollary bispannability property\n-}\n\n\n\nbispansNulltailcolExtension : downAndNotRightOfEntryImpliesZ (x::xs) FZ FZ\n\t-> ys `bispanslz` map Vect.tail xs\n\t-> map ((Pos Z)::) ys `bispanslz` xs\nbispansNulltailcolExtension = bispansNullcolExtension . danrzTailHasLeadingZeros\n\n\n\n{-\nRow echelon properties\n\nDefinitions\n* (echPreTy) The per-row component of (rowEchelonPre)\n* (rowEchelonPre) The row echelon property in terms of (leadingNonzeroNum) & its correctness\n* (echTy) The per-row component of (rowEchelon)\n* (rowEchelon) The row echelon property -- (rowEchelonPre) but with numbers having the leading nonzero property (leadingNonzeroProp) -- inferable about (leadingNonzeroNum) using (leadingNonzeroProof), hence inferable from a given (rowEchelonPre) proof.\n\nTheorems\n* rowEchelonPreZeroHeight\n* rowEchelonPreExtension\n\tInducing gaussian elimination verification from the lesser height & width cases,\n\tdone when first column is nonzero.\n* echelonPreNullcolExtension\n\tInducing gaussian elimination from the lesser width cases,\n\tdone when first column is zero.\n* echelonPreFromDanrzLast\n\tFor verifying gaussian elimination in the width = 1 case\n* toEchTy\n* toRowEchelon\n-}\n\n\n\nechPreTy : (xs : Matrix n m ZZ) -> (nel : Fin n) -> Type\nechPreTy {n} {m} xs nel =\n\tEither\n\t\t((nelow : Fin n) -> (ltpr : finToNat nel `LTERel` finToNat nelow)\n\t\t\t-> index nelow xs = Algebra.neutral)\n\t\t(mel : Fin m ** (leadingNonzeroNum $ index nel xs = Just mel\n\t\t\t, downAndNotRightOfEntryImpliesZ xs nel mel))\n\n{-\nLemma about left case of (echPreTy):\n\nEverything zero below or at a row of xs\n=>\nfor all (x::xs)\nfor mel = last\ndownAndNotRightOfEntryImpliesZ xs nel mel\n\nSee also (echelonFromDanrzLast),\nthe converse (danrzLastcolImpliesTailNeutral) of this from (ZZGaussianElimination)\n-}\n\nrowEchelonPre : (xs : Matrix n m ZZ) -> Type\nrowEchelonPre {n} {m} xs = (narg : Fin n) -> echPreTy xs narg\n\n||| For best results, prove in terms of `echPreTy` using `toEchTy`\nechTy : (xs : Matrix n m ZZ) -> (nel : Fin n) -> Type\nechTy {n} {m} xs nel =\n\tEither\n\t\t((nelow : Fin n) -> (ltpr : finToNat nel `LTERel` finToNat nelow)\n\t\t\t-> index nelow xs = Algebra.neutral)\n\t\t(mel : Fin m ** (leadingNonzeroProp (index nel xs) (Just mel)\n\t\t\t, downAndNotRightOfEntryImpliesZ xs nel mel))\n\n||| For best results, prove in terms of `rowEchelonPre` using `toRowEchelon`\nrowEchelon : (xs : Matrix n m ZZ) -> Type\nrowEchelon {n} {m} xs = (narg : Fin n) -> echTy xs narg\n\n\n\nrowEchelonPreZeroHeight : rowEchelonPre []\nrowEchelonPreZeroHeight = \\narg => FinZElim narg\n\nrowEchelonPreZeroWidth : rowEchelonPre $ replicate n []\nrowEchelonPreZeroWidth = \\narg => Left $ \\_ => \\_ => indexReplicateChariz\n\nrowEchelonPreExtension :\n\t{x : Vect (S predm) ZZ}\n\t-> {xs : Matrix n predm ZZ}\n\t-> leadingNonzeroNum x = Just FZ\n\t-> rowEchelonPre xs\n\t-> rowEchelonPre $ x :: map ((Pos 0)::) xs\nrowEchelonPreExtension {n} {predm} {x} {xs} lnz ech FZ =\n\tRight (FZ ** (lnz, danrzFn))\n\twhere\n\t\tdanrzFn : (i : Fin (S n))\n\t\t\t-> (j : Fin (S predm))\n\t\t\t-> LTE 1 (finToNat i)\n\t\t\t-> Either (LTE (S (finToNat j)) 0) (finToNat j = 0)\n\t\t\t-> indices i j $ x :: map ((Pos 0)::) xs = Pos 0\n\t\tdanrzFn FZ _ lteOZ _ = void $ succNotLTEzero lteOZ\n\t\t{- column 0 and row > 0 to x::(0-col|xs) is index 0 to a 0::(xs!i) is 0 -}\n\t\tdanrzFn (FS k) j _ orJZ\n\t\t\t= rewrite\n\t\t\teither (void . succNotLTEzero) (finToNatInjective j FZ) orJZ\n\t\t\tin indicesConstColChariz\nrowEchelonPreExtension {n} {predm} {x} {xs} lnz ech (FS narg) with ( ech narg )\n\t{-\n\tLeft case\n\t---\n\n\tOutline:\n\n\tindices i j xs = Pos Z <=> index j $ index i xs = Pos Z\n\n\tindex nelow xs = replicate predm (Pos 0)\n\t<=> forall j, index j $ index nelow xs = Pos Z\n\n\tConsider:\n\n\tlteSuccRight :: LTE (S m) n -> LTE (S m) (S n)\n\n\tConsider this context:\n\n\tintros\n\texact Left _\n\tintro snelow\n\tintro ltReSnelow\n\n\tBut instead we do:\n\n\texact Left _\n\tintro snelow\n\teither snelow is FZ or snellow is FS k.\n\tIf snelow is FZ, we need to show (index FZ $ x::_ = 0 === x = 0),\n\t\tso we must show snelow can't be FZ\n\t\twhich follows from (ltReSnelow) being an either of two\n\t\tcharacterizations of (finToNat snelow) as a successor.\n\tIf snelow is (FS predsnelow), we need to show\n\t\t(index predsnelow xs = 0),\n\twhich follows from (neutfn predsnelow)\n\tgiven a weakening of the LTE\n\t-}\n\t| Left neutfn = Left zFn\n\t\twhere\n\t\t\tzFn : (snelow : Fin (S n))\n\t\t\t\t-> Either\n\t\t\t\t\t((S $ finToNat narg) `LTRel` (finToNat snelow))\n\t\t\t\t\t(S $ finToNat narg = finToNat snelow)\n\t\t\t\t-> index snelow $ x :: map ((Pos 0)::) xs\n\t\t\t\t\t= Algebra.neutral\n\t\t\tzFn FZ ltReSnelow = void\n\t\t\t\t$ either succNotLTEzero SIsNotZ ltReSnelow\n\t\t\tzFn (FS predsnelow) ltReSnelow = trans indexMapChariz\n\t\t\t\t$ cong $ neutfn predsnelow\n\t\t\t\t$ either\n\t\t\t\t\t(Left . fromLteSucc)\n\t\t\t\t\t(Right . succInjective\n\t\t\t\t\t\t(finToNat narg)\n\t\t\t\t\t\t(finToNat predsnelow))\n\t\t\t\t\tltReSnelow\n\t{-\n\tRight case\n\t---\n\n\t* lnzJMelEq -> lnzJMelEq' :\n\t\tIf (leadingNonzeroNum xs!narg = Just mel),\n\t\tso will the extension (x::(0-col|xs)) have (Just (FS mel)) at (FS narg)\n\t* See (danrzFn) comments\n\t-}\n\t| Right (mel ** (lnzJMelEq, danrzNelMel))\n\t\t= Right (FS mel **\n\t\t\t\t(trans (cong {f=leadingNonzeroNum} indexMapChariz)\n\t\t\t\t\t$ cong {f=map FS} lnzJMelEq\n\t\t\t\t, danrzFn))\n\t\twhere\n\t\t\t{-\n\t\t\tWhen i and j a successor, apply danrzNelMel.\n\t\t\tWhen i a successor and j = 0, const (const Refl).\n\t\t\tWhen i = 0, the LTE is absurd.\n\t\t\t-}\n\t\t\tdanrzFn : (i : Fin (S n))\n\t\t\t\t-> (j : Fin (S predm))\n\t\t\t\t-> (S $ finToNat narg) `LTRel` (finToNat i)\n\t\t\t\t-> Either ((finToNat j) `LTRel` (S $ finToNat mel))\n\t\t\t\t\t(finToNat j = S $ finToNat mel)\n\t\t\t\t-> indices i j $ x :: map ((Pos 0)::) xs = Pos 0\n\t\t\tdanrzFn FZ _ ltNI _ = void $ succNotLTEzero ltNI\n\t\t\tdanrzFn (FS i') FZ ltNI ltJSM = indicesConstColChariz\n\t\t\tdanrzFn (FS i') (FS j') ltNI ltJSM\n\t\t\t\t= trans indicesConstColChariz2\n\t\t\t\t\t$ danrzNelMel i' j' ltNI' ltJSM'\n\t\t\t\twhere\n\t\t\t\t\tltNI' = fromLteSucc ltNI\n\t\t\t\t\tltJSM' = either\n\t\t\t\t\t\t(Left . fromLteSucc)\n\t\t\t\t\t\t(Right . succInjective\n\t\t\t\t\t\t\t(finToNat j')\n\t\t\t\t\t\t\t(finToNat mel))\n\t\t\t\t\t\tltJSM\n\nechelonPreNullcolExtension :\n\t{xs : Matrix n predm ZZ}\n\t-> rowEchelonPre xs\n\t-> rowEchelonPre $ map ((Pos 0)::) xs\nechelonPreNullcolExtension {n} {predm} {xs} ech narg with ( ech narg )\n\t| Left neutfn = Left $ \\nelow => \\ltpr =>\n\t\ttrans indexMapChariz\n\t\t$ cong {f=((Pos 0)::)} $ neutfn nelow ltpr\n\t| Right (mel ** (lnzJMelEq, danrzNelMel))\n\t\t= Right (FS mel **\n\t\t\t(trans (cong {f=leadingNonzeroNum} indexMapChariz)\n\t\t\t$ cong {f=map FS} lnzJMelEq\n\t\t\t, danrzFn))\n\t\twhere\n\t\t\t{-\n\t\t\tWhen j = 0, const (const Refl)\n\t\t\tWhen j a successor, apply (danrzNelMel).\n\t\t\t-}\n\t\t\tdanrzFn : (i : Fin n)\n\t\t\t\t-> (j : Fin (S predm))\n\t\t\t\t-> finToNat narg `LTRel` finToNat i\n\t\t\t\t-> finToNat j `LTERel` (S $ finToNat mel)\n\t\t\t\t-> indices i j $ map ((Pos 0)::) xs = Pos 0\n\t\t\tdanrzFn i FZ _ _ = indicesConstColChariz\n\t\t\tdanrzFn i (FS j') ltNI ltJSM = trans indicesConstColChariz2\n\t\t\t\t$ danrzNelMel i j' ltNI\n\t\t\t\t$ either\n\t\t\t\t\t(Left . fromLteSucc)\n\t\t\t\t\t(Right . succInjective\n\t\t\t\t\t\t(finToNat j')\n\t\t\t\t\t\t(finToNat mel))\n\t\t\t\t\tltJSM\n\n\n\nechelonPreFromDanrzLast :\n\t{mat : Matrix (S n) (S mu) ZZ}\n\t-> downAndNotRightOfEntryImpliesZ mat FZ (last {n=mu})\n\t-> rowEchelonPre mat\nechelonPreFromDanrzLast {mat=x::xs} {n} {mu} danrz FZ with (leadingNonzeroProof {v=x})\n\t| Left nothPrAndZeroPr = Left echelonPreFromDanrzLast_Nothing\n\twhere\n\t\techelonPreFromDanrzLast_Nothing :\n\t\t\t(nelow : Fin (S n))\n\t\t\t-> (ltepr : Either (0 `LT` finToNat nelow) (0 = finToNat nelow))\n\t\t\t-> index nelow (x::xs) = Algebra.neutral\n\t\techelonPreFromDanrzLast_Nothing nelow (Left ltpr)\n\t\t\t= trans\n\t\t\t\t(cong {f=\\ts => Vect.index nelow (x::ts)}\n\t\t\t\t$ danrzLastcolImpliesTailNeutral {x=x} {xs=xs} danrz)\n\t\t\t$ trans (cong {f=(\\i => Vect.index i (x::Algebra.neutral))}\n\t\t\t\t$ getProof $ gtnatFZImpliesIsFinSucc nelow ltpr)\n\t\t\t$ indexNeutralIsNeutral2D _\n\t\techelonPreFromDanrzLast_Nothing nelow (Right eqpr)\n\t\t\t= rewrite sym $ finToNatInjective FZ nelow eqpr\n\t\t\tin snd nothPrAndZeroPr\n\t| Right (mel ** melpr)\n\t\t= Right $ (mel ** (fst melpr, danrzLastcolImpliesAllcol {mel=mel} danrz))\nechelonPreFromDanrzLast {mat=x::xs} danrz (FS k) with (leadingNonzeroProof {v=index k xs})\n\t| Left nothPrAndZeroPr = Left echelonPreFromDanrzLast_Nothing2\n\twhere\n\t\techelonPreFromDanrzLast_Nothing2 :\n\t\t\t(nelow : Fin (S _))\n\t\t\t-> (ltepr : Either\n\t\t\t\t(finToNat (FS k) `LT` finToNat nelow)\n\t\t\t\t(finToNat (FS k) = finToNat nelow))\n\t\t\t-> index nelow (x::xs) = Algebra.neutral\n\t\techelonPreFromDanrzLast_Nothing2 nelow (Left ltpr)\n\t\t\t= trans\n\t\t\t\t(cong {f=\\ts => Vect.index nelow (x::ts)}\n\t\t\t\t$ danrzLastcolImpliesTailNeutral {x=x} {xs=xs} danrz)\n\t\t\t$ trans (cong {f=(\\i => Vect.index i (x::Algebra.neutral))}\n\t\t\t\t$ getProof $ gtnatFZImpliesIsFinSucc nelow\n\t\t\t\t$ natGtAnyImpliesGtZ\n\t\t\t\t\t(S $ finToNat k) (finToNat nelow) ltpr)\n\t\t\t$ indexNeutralIsNeutral2D _\n\t\techelonPreFromDanrzLast_Nothing2 nelow (Right eqpr)\n\t\t\t= rewrite sym $ finToNatInjective (FS k) nelow eqpr\n\t\t\tin snd nothPrAndZeroPr\n\t| Right (mel ** melpr) = void $ (snd $ snd melpr)\n\t\t$ flip trans (indexNeutralIsNeutral1D mel)\n\t\t$ cong {f=index mel}\n\t\t$ trans (cong {f=index k}\n\t\t\t$ danrzLastcolImpliesTailNeutral {x=x} {xs=xs} danrz)\n\t\t$ indexNeutralIsNeutral2D k\n\n\n\ntoEchTy : echPreTy xs nel -> echTy xs nel\ntoEchTy ech = map prrw ech\n\twhere\n\t\tprrw (mel ** (pr, danrz))\n\t\t\t= (mel ** (rewrite sym pr in leadingNonzeroProof, danrz))\n\ntoRowEchelon : rowEchelonPre xs -> rowEchelon xs\ntoRowEchelon echxs = \\narg => toEchTy (echxs narg)\n", "meta": {"hexsha": "0948e2dd6ed22ca6596798ec1ced0de0c7a3b287", "size": 19206, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Data/Matrix/RowEchelon.idr", "max_stars_repo_name": "runKleisli/verified-integer-gaussian-elimination", "max_stars_repo_head_hexsha": "cbaed9c2d8d77db25bd13c8c53beea8ac320855c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2016-07-12T15:25:52.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-14T05:43:48.000Z", "max_issues_repo_path": "Data/Matrix/RowEchelon.idr", "max_issues_repo_name": "runKleisli/verified-integer-gaussian-elimination", "max_issues_repo_head_hexsha": "cbaed9c2d8d77db25bd13c8c53beea8ac320855c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 16, "max_issues_repo_issues_event_min_datetime": "2016-06-10T02:31:24.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-07T16:16:50.000Z", "max_forks_repo_path": "Data/Matrix/RowEchelon.idr", "max_forks_repo_name": "runKleisli/verified-integer-gaussian-elimination", "max_forks_repo_head_hexsha": "cbaed9c2d8d77db25bd13c8c53beea8ac320855c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 32.01, "max_line_length": 333, "alphanum_fraction": 0.6885868999, "num_tokens": 6898, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.7431680029241321, "lm_q1q2_score": 0.5913076412343435}}
{"text": "module Regex\n\n-- Based on https://homepage.divms.uiowa.edu/~astump/papers/stump-icfp20.pdf\n\ndata ListF : Type -> Type -> Type where\n Nil : ListF a f\n Cons : a -> f -> ListF a f\n\ndata StdRegF : (r : Type) -> Type where\n NoMatch : StdRegF r\n MatchChar : Char -> StdRegF r\n Or : r -> r -> StdRegF r\n Plus : r -> StdRegF r\n Concat : r -> r -> StdRegF r\n\ndata Mu : (f : Type -> Type) -> Type where\n In : (f (Mu f)) -> Mu f\n\nList' : Type -> Type\nList' a = Mu (ListF a)\n\nnil : List' a\nnil = In Nil\n\nisNil : List' a -> Bool\nisNil (In []) = False\nisNil (In (Cons x xs)) = True\n\n(::) : a -> List' a -> List' a\n(::) x xs = In (Cons x xs)\n\nstr : String -> List' Char\nstr xs = str' $ unpack xs\n where str' : List Char -> List' Char\n str' [] = In $ Nil\n str' (x :: xs) = In $ Cons x (str' xs)\n\nStdReg : Type\nStdReg = Mu StdRegF\n\nchar : Char -> StdReg\nchar c = In $ MatchChar c\n\nconcat : StdReg -> StdReg -> StdReg\nconcat r1 r2 = In $ Concat r1 r2\n\nor : StdReg -> StdReg -> StdReg\nor r1 r2 = In $ Or r1 r2\n\nplus : StdReg -> StdReg\nplus r = In $ Plus r\n\nMcatapnAlg : (f : Type -> Type) -> (x : Type -> Type) -> Type\nMcatapnAlg f x = {r : Type} -> (r -> x r) -> (r -> Mu f) -> f r -> x r\n\nmcatapn : McatapnAlg f x -> Mu f -> x (Mu f)\nmcatapn alg (In d) = alg (mcatapn alg) id d\n\nK : Type -> Type\nK t = t -> Bool\n\nMatchT : Type -> Type\nMatchT t = K t -> Bool\n\nmatchi : {t : Type} -> (t -> StdReg -> MatchT t) -> StdReg -> Char -> t -> MatchT t\nmatchi {t} match reg = mcatapn {x = MatchiX t} alg reg\n where MatchiX : (t : Type) -> (r : Type) -> Type\n MatchiX t _ = Char -> t -> MatchT t\n alg : McatapnAlg StdRegF (MatchiX t)\n alg eval _ NoMatch c cs k = False\n alg eval _ (MatchChar c') c cs k = if c == c' then k cs else False\n alg eval _ (Or r1 r2) c cs k = eval r1 c cs k || eval r2 c cs k\n alg eval reveal (Plus r) c cs k = eval r c cs (\\cs => k cs || match cs (In (Plus $ reveal r)) k)\n alg eval reveal (Concat r1 r2) c cs k = eval r1 c cs (\\cs => match cs (reveal r2) k)\n\n\nmatch : List' Char -> StdReg -> Bool\nmatch xs reg = mcatapn alg xs reg (\\_ => True)\n where MatchX : Type -> Type\n MatchX r = StdReg -> MatchT r\n alg : McatapnAlg (ListF Char) MatchX\n alg eval _ Nil r k = False\n alg eval _ (Cons c cs) r k = matchi eval r c cs k\n\nexample : StdReg\nexample = concat (concat (char 'c') (plus $ or (char 'a') (char 'd'))) (char 'r')\n\ntest0 : Bool\ntest0 = match (str \"car\") example\n\ntest1 : Bool\ntest1 = match (str \"cdr\") example\n\ntest2 : Bool\ntest2 = match (str \"cr\") example\n\ntest3 : Bool\ntest3 = match (str \"cddar\") example\n\ntest4 : Bool\ntest4 = match (str \"cdda\") example\n", "meta": {"hexsha": "5990f19ddce99c9ac0f115fefbb324b31eea09a7", "size": 2670, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Regex.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/Regex.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/Regex.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.1764705882, "max_line_length": 104, "alphanum_fraction": 0.5715355805, "num_tokens": 962, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094145755219, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.591301942677357}}
{"text": "module Data.Queue\n\nimport Data.Vect\nimport Data.VectRankedElem\nimport Decidable.Order\n\n%default total\n\nexport\ndata Queue : (size : Nat) -> (ty : Type) -> Type where\n MkQueue : {n : Nat}\n -> (f : Vect n ty)\n -> {m : Nat}\n -> (r : Vect m ty)\n -> .{auto invariant : LTE m n}\n -> Queue (n + m) ty\n\nqueues : {ty : Type} -> Queue _ ty -> ((size1 : Nat ** Vect size1 ty),\n (size2 : Nat ** Vect size2 ty))\nqueues (MkQueue {n} f {m} r) = ((n ** f), (m ** r))\n\nexport\ndata RankedElem : ty -> Queue size ty -> (idx : Nat) -> Type where\n FrontElem : {q : Queue size ty}\n -> {idx : Nat}\n -> RankedElem x (snd $ fst $ queues q) idx\n -> RankedElem x q idx\n BackElem : {q : Queue size ty}\n -> {idx : Nat}\n -> RankedElem x (snd $ snd $ queues q) idx\n -> RankedElem x q (size `minus` S idx)\n\nexport\nempty : Queue Z _\nempty = MkQueue [] []\n\nlteAddRightLemma : LTE r c -> LTE r (l + c)\nlteAddRightLemma {l} {r} {c} smaller\n = lteTransitive smaller cLTElc\n where cLTElc : LTE c (l + c)\n cLTElc = rewrite plusCommutative l c in\n lteAddRight {m = l} c\n\nminusPlusEqualsPlusMinus : (l, c, r: Nat) -> LTE r c -> LTE r (l + c) -> (l + c) - r = l + (c - r)\nminusPlusEqualsPlusMinus Z _ _ _ _ = Refl\nminusPlusEqualsPlusMinus (S _) Z Z _ _ = Refl\nminusPlusEqualsPlusMinus (S _) (S _) Z _ _ = Refl\nminusPlusEqualsPlusMinus _ Z (S _) _ _ impossible\nminusPlusEqualsPlusMinus l (S c) (S r) smaller _\n = let smaller' = fromLteSucc smaller in\n rewrite sym $ plusSuccRightSucc l c in\n minusPlusEqualsPlusMinus l c r smaller' (lteAddRightLemma smaller')\n\nmake_ : {n : Nat}\n -> (f : Vect n ty)\n -> {m : Nat}\n -> (r : Vect m ty)\n -> (ret : Queue (n + m) ty\n ** ({x : ty} -> {idx : Nat} -> RankedElem x f idx -> RankedElem x ret idx,\n {x : ty} -> {idx : Nat} -> RankedElem x r idx -> RankedElem x ret (n + m `minus` S idx)))\nmake_ {n} f {m} r with (order {to = LTE} m n)\n | Left _ = (MkQueue f r ** (FrontElem, BackElem))\n | Right _ = let (reversed ** rProj) = rev_ r\n (f' ** (fProj, reversedProj)) = f `concat_` reversed in\n rewrite sym $ plusZeroRightNeutral (n + m) in\n (MkQueue f' [] ** (FrontElem . fProj,\n rewrite plusZeroRightNeutral (n + m) in\n FrontElem . (proj $ reversedProj . rProj)))\n where proj : {f' : Vect (n + m) ty}\n -> (trans : {x : ty} -> {idx : Nat} -> RankedElem x r idx -> RankedElem x f' (n + (m `minus` S idx)))\n -> {x : ty} -> {idx' : Nat} -> RankedElem x r idx'\n -> RankedElem x f' (n + m `minus` S idx')\n proj {f'} trans {idx'} elem = let smaller = indexSmallerThanSize elem\n elem' = trans elem in\n rewrite assert_total $\n minusPlusEqualsPlusMinus n m (S idx') smaller (lteAddRightLemma smaller) in\n elem'\n\nexport\nsnoc_ : (q : Queue size ty) -> (x : ty)\n -> (ret : Queue (S size) ty\n ** ({x : ty} -> {idx : Nat} -> RankedElem x q idx -> RankedElem x ret idx,\n RankedElem x ret size))\nsnoc_ (MkQueue {n} f {m} r) x = rewrite plusSuccRightSucc n m in\n let (ret ** (fProj, rProj)) = make_ f (x::r) in\n (ret ** ((\\el => case el of\n (FrontElem el) => fProj el\n (BackElem el {idx}) => rewrite sym $ lemma n m (S idx) in\n rProj $ There el),\n rewrite sym $ minusZeroRight (n + m) in\n rewrite sym $ lemma n m Z in\n rProj Here))\n where lemma : (l, c, r : Nat) -> l + S c `minus` S r = l + c `minus` r\n lemma Z Z _ = Refl\n lemma Z (S _) _ = Refl\n lemma (S l) c r = rewrite plusSuccRightSucc l c in Refl\n\nexport\nsnoc : Queue size ty -> ty -> Queue (S size) ty\nsnoc q x = fst $ snoc_ q x\n\nexport\nhead_ : (q : Queue (S _) ty) -> (x : ty ** RankedElem x q Z)\nhead_ (MkQueue (x :: xs) ys) = (x ** FrontElem Here)\n\nexport\nhead : Queue (S _) ty -> ty\nhead q = fst $ head_ q\n\nexport\ntail_ : (q : Queue (S size) ty)\n -> (ret : Queue size ty\n ** {x : ty} -> {idx : Nat} -> RankedElem x q (S idx) -> RankedElem x ret idx)\ntail_ (MkQueue (_::fs) r)\n = let (ret ** (fProj, rProj)) = make_ fs r in\n (ret ** \\el =>\n case toPattern el of\n (Z ** (_, Refl)) impossible\n (S _ ** (FrontElem (There x), Refl)) => fProj x\n (_ ** (BackElem x, prf)) => rewrite toMinusSuccPredEq prf in rProj x)\n where toPattern : {q : Queue (S _) ty}\n -> {i : Nat}\n -> RankedElem x q (S i)\n -> (i' ** (RankedElem x q i', S i = i'))\n toPattern {i} el = (S i ** (el, Refl))\n toMinusSuccPredEq : S c = x + y `minus` z -> c = x + y `minus` S z\n toMinusSuccPredEq {x} {y} {z} prf = rewrite minusSuccPred (x + y) z in cong {f = Nat.pred} prf\n\nexport\ntail : Queue (S size) ty -> Queue size ty\ntail q = fst $ tail_ q\n", "meta": {"hexsha": "3ee2a6877442e4ca528d8ede59ae76fe30cd9446", "size": 5610, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Queue.idr", "max_stars_repo_name": "jdevuyst/idris-data", "max_stars_repo_head_hexsha": "dab40425d208a09a9cf2ce4dadcf73b053522c1a", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2017-08-02T11:18:49.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-07T12:32:38.000Z", "max_issues_repo_path": "src/Data/Queue.idr", "max_issues_repo_name": "jdevuyst/idris-data", "max_issues_repo_head_hexsha": "dab40425d208a09a9cf2ce4dadcf73b053522c1a", "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/Queue.idr", "max_forks_repo_name": "jdevuyst/idris-data", "max_forks_repo_head_hexsha": "dab40425d208a09a9cf2ce4dadcf73b053522c1a", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 2, "max_forks_repo_forks_event_min_datetime": "2020-11-16T09:13:41.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-16T20:00:26.000Z", "avg_line_length": 42.5, "max_line_length": 133, "alphanum_fraction": 0.4682709447, "num_tokens": 1609, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.870597265050901, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.5912911179829258}}
{"text": "module LambdaSKI\n\n-- Based on http://okmij.org/ftp/tagless-final/ski.pdf\n\ndata HasType : List a -> a -> Type where\n VZ : HasType (t :: env) t\n VS : HasType env t -> HasType (_ :: env) t\n\ndata Expr : List Type -> Type -> Type where\n Var : HasType env t -> Expr env t\n Lam : Expr (a :: env) b -> Expr env (a -> b)\n App : Expr env (a -> b) -> Expr env a -> Expr env b\n\ndata SKI : Type -> Type where\n KI : SKI (a -> a)\n KK : SKI (a -> b -> a)\n KS : SKI ((a -> b -> c) -> (a -> b) -> a -> c)\n KB : SKI ((a -> b) -> (c -> a) -> c -> b)\n KC : SKI ((a -> b -> c) -> b -> a -> c)\n KApp : SKI (a -> b) -> SKI a -> SKI b\n\ndata Repr : List Type -> Type -> Type where\n C : SKI a -> Repr env a\n N : Repr env (a -> b) -> Repr (a :: env) b\n W : Repr env a -> Repr (_ :: env) a\n\napp : Repr env (a -> b) -> Repr env a -> Repr env b\napp (C x) (C y) = C $ KApp x y\napp (C x) (N y) = N $ app (C (KApp KB x)) y\napp (C x) (W y) = W $ app (C x) y\napp (N x) (C y) = N $ app (C (KApp (KApp KC KC) y)) x\napp (N x) (N y) = N $ app (app (C KS) x) y\napp (N x) (W y) = N $ app (app (C KC) x) y\napp (W x) (C y) = W $ app x (C y)\napp (W x) (N y) = N $ app (app (C KB) x) y\napp (W x) (W y) = W $ app x y\n\nconv : Expr env a -> Repr env a\nconv (Var VZ) = N $ C KI\nconv (Var (VS x)) = W $ conv (Var x)\nconv (Lam x) with (conv x)\n conv (Lam x) | (C y) = C $ KApp KK y\n conv (Lam x) | (N y) = y\n conv (Lam x) | (W y) = app (C KK) y\nconv (App f x) = app (conv f) (conv x)\n\ncomp : Expr [] a -> SKI a\ncomp expr with (conv expr)\n comp expr | (C x) = x\n\nexample : Expr [] ((() -> ()) -> () -> ())\nexample = Lam (Lam (App (Var (VS VZ)) (Var VZ)))\n\ntest : SKI ((() -> ()) -> () -> ())\ntest = comp example\n", "meta": {"hexsha": "f0c9a0d2687661d3ee7e6f170f5aee6701009734", "size": 1678, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/LambdaSKI.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/LambdaSKI.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/LambdaSKI.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": 29.9642857143, "max_line_length": 54, "alphanum_fraction": 0.4845053635, "num_tokens": 709, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199633332891, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.5911796291380218}}
{"text": "module Ch05.LambdaCalculusWithArith\n\nimport Ch03.Relations\n\n%default total\n%access public export\n\n--------------------------------------------------------------------------------\n-- The lambda calculus extended by native arithmetic expressions.\n--------------------------------------------------------------------------------\n--\n-- Remark: It kinda sucks to have to repeat the definitions of the lambda\n-- calculus and the language of arithmetic expressions. In particular because\n-- in the book Pierce doesn't even bother to write down the language and simply\n-- waves his hands. So you expect to be able to just formally combine the two\n-- languages.\n-- However, I don't know a convenient way to do that since Idris has no subtyping.\n-- It would be possible to define something like\n--\n-- data Term = Lambda Ch05.LambdaCalculus.Term\n-- | Arith Ch03.Arith.Term\n--\n-- but that would be kinda awkward.\n--\n-- TL;DR: I'm just gonna repeat definitions as that seems simpler.\n--------------------------------------------------------------------------------\n\n||| The type of variables\nVariable : Type\nVariable = Nat\n\n-- Pierce doesn't bother to actually define this calculus (neither in the book\n-- nor the software available at https://www.cis.upenn.edu/~bcpierce/tapl).\n-- So I'm using the simplest, most naive definition I can imagine here.\n||| Terms in the lambda calculus extended by arithmetic expressions.\ndata Term = True\n | False\n | IfThenElse Term Term Term\n | Zero\n | Succ Term\n | Pred Term\n | IsZero Term\n | Var Variable\n | Abs Variable Term\n | App Term Term\n\n||| Convenient infix notation for construction of function application terms\n(.) : Term -> Term -> Term\n(.) = App\n\n-- TODO: Can we get rid of the argument `n`?\n||| Convenience function for constructing lambda terms\nlambda : Nat -> (Term -> Term) -> Term\nlambda n f = Abs n (f (Var n))\n\n\n-----------------------------------------------------------------------\n-- The stuff below is literally copy pasted from Ch05.LambdaCalculus\n\n--------------------------------------------------------------------------------\n-- Booleans\n--------------------------------------------------------------------------------\n\n||| The Church boolean true\ntru : Term\ntru = Abs 1 (Abs 0 (Var 1))\n\n||| The Church boolean false\nfls : Term\nfls = Abs 1 (Abs 0 (Var 0))\n\n||| Church encoding of the if-then-else operator\ntest : Term\ntest = Abs 2 (Abs 1 (Abs 0 (App (App (Var 2) (Var 1)) (Var 0))))\n\n||| Logical AND operator for Church booleans.\nand : Term\nand = Abs 0 (Abs 1 (App (App (Var 0) (Var 1)) fls))\n\n--------------------------------------------------------------------------------\n-- Pairs\n--------------------------------------------------------------------------------\n\n||| Church pair constructor\npair : Term\npair = Abs 0 (Abs 1 (Abs 2 (App (App (Var 2) (Var 0)) (Var 1))))\n\n||| Projection onto the first component of a pair\nfst : Term\nfst = Abs 0 (Abs 1 (Var 0))\n\n||| Projection onto the second component of a pair\nsnd : Term\nsnd = Abs 0 (Abs 1 (Var 1))\n\n--------------------------------------------------------------------------------\n-- Numerals\n--------------------------------------------------------------------------------\n\n||| The Church numeral zero.\nchurch_zero : Term\nchurch_zero = Abs 1 (Abs 0 (Var 0))\n\n||| The Church numeral one.\nchurch_one : Term\nchurch_one = Abs 1 (Abs 0 (App (Var 1) (Var 0)))\n\n||| The Church numeral two.\nchurch_two : Term\nchurch_two = Abs 1 (Abs 0 (App (Var 1) (App (Var 1) (Var 0))))\n\n||| The successors function for Church numerals\nscc : Term\nscc = Abs 0 (Abs 1 (Abs 2 (App (Var 1) (App (App (Var 0) (Var 1)) (Var 2)))))\n\n||| Addition of Church numerals\nplus : Term\nplus = Abs 0 (Abs 1 (Abs 2 (Abs 3 ((Var 0) . (Var 2)) . (((Var 1) . (Var 2)) . (Var 3)))))\n\n||| Multiplication of Church numerals\ntimes : Term\ntimes = Abs 0 (Abs 1 ((Var 0) . (plus . (Var 1))) . church_zero)\n\n||| Tests whether a Church numeral is zero or not\niszro : Term\niszro = Abs 0 ((Var 0) . (Abs 0 fls)) . tru\n\n||| The predecessor function on Church numerals\nprd : Term\nprd = let zz = pair . church_zero . church_zero\n ss = Abs 0 (pair . (snd . (Var 0)) . (scc . (snd . (Var 0)))) in\n Abs 0 (fst . ((Var 0) . ss) . zz)\n\n--------------------------------------------------------------------------------\n-- Lists\n--------------------------------------------------------------------------------\n\n-- See Ch05.Exercise_5_2_8\n\n--------------------------------------------------------------------------------\n-- Self-replicating terms\n--------------------------------------------------------------------------------\n\n||| The (?) simplest self-replicating term in the lambda calculus\nomega : Term\nomega = let x = Var 0\n f = Abs 0 (x . x) in\n f . f\n\n||| The call-by-value version of the fix-point combinator (i.e. Y combinator)\nfix : Term\nfix = let f = Var 0\n x = Var 1\n y = Var 2\n t = Abs 1 f . (Abs 2 (x . x . y)) in\n Abs 0 (t . t)\n\n\n-----------------------------------------------------------------------\n-- Copy pasted exercises\n\n||| `sub m n` yields the result of subtracting `n` from `m` (Church numerals).\n|||\n||| More precisely, it yields the smallest church numeral `z` such that\n|||\n||| m <= n+z\nsub : Term\nsub = let m = Var 0\n n = Var 1 in\n Abs 0 (Abs 1 (n . prd) . m)\n\n||| `le m n` tests whether `m` is less than or equal to `n`\nle : Term\nle = let m = Var 0\n n = Var 1 in\n Abs 0 (Abs 1 (iszro . (sub . m . n)))\n\n||| Test whether two Church numerals are equal\nequal : Term\nequal = let m = Var 0\n n = Var 1\n m_le_n = le . m . n\n n_le_m = le . n . m in\n Abs 0 (Abs 1 (and . m_le_n . n_le_m))\n\n-----------------------------------------------------------------------\n-- Stuff below is lifted wholesale from exercise 5.2.8\n\n-- Lists are represented by their corresponding fold function. That is, a list\n-- [x, y, z] is identified with the function\n--\n-- f |-> ( c |-> f x (f y (f z c))) )\n-- \n-- Where f is any 2-ary function (since the untyped lambda calculus is untyped, of\n-- course we can't talk about arities).\n\n||| The term representing the empty list\nnil : Term\nnil = Abs 0 (Abs 1 (Var 1))--?nil_rhs\n\n||| The term representing the cons combinator\ncons : Term\ncons = let car = Var 0 -- not to be confused with the car combinator below\n cdr = Var 1 -- --------------------------- cdr ----------------\n f = Var 2\n c = Var 3 in\n Abs 0 (Abs 1 (Abs 2 (Abs 3 (f . car . (cdr . f . c)))))\n\n||| Checks whether a list is nil\nisnil : Term\nisnil = let l = Var 0\n f = Abs 1 (Abs 2 fls) in\n Abs 0 (l . f . tru)\n\n||| The term representing the \"car\" combinator\nhead : Term\nhead = let l = Var 0 in\n Abs 0 l . fst . nil\n\n||| The term representing the \"cdr\" combinator\ntail : Term\ntail = let l = Var 0\n x = Var 1\n y = Var 2\n f = Abs 1 (Abs 2 pair . (snd . y) . (cons . x . (snd . y)))\n c = pair . nil . nil in\n Abs 0 (fst . (l . f . c))\n\n-----------------------------------------------------------------------\n-- Stuff below is not copy pasted.\n\n||| Term representing a function converting Church booleans into \"real\" booleans.\nrealbool : Term\nrealbool = lambda 0\n (\\b => b . True . False)\n\n||| Term representing a function converting \"real\" booleans to Church booleans.\nchurchbool : Term\nchurchbool = lambda 0\n (\\b => IfThenElse b tru fls)\n\n||| Term representing a function of two arguments returning a \"real\" boolean\n||| specifying whether they are equal or not, at least if both arguments provided\n||| are Church numerals.\nrealeq : Term\nrealeq = lambda 0\n (\\m => lambda 1\n (\\n => (equal . m . n) . True . False))\n\n||| Term representing a function converting a Church numeral into a primitive natural number\nrealnat : Term\nrealnat = lambda 0\n (\\n => n . (lambda 1 (\\x => Succ x)) . church_zero) -- TODO: Rename church_zero to c0 etc.\n", "meta": {"hexsha": "f9f69d769176164170bbc3edaa434f4d563e851a", "size": 8147, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Ch05/LambdaCalculusWithArith.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": "Ch05/LambdaCalculusWithArith.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": "Ch05/LambdaCalculusWithArith.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": 32.0748031496, "max_line_length": 107, "alphanum_fraction": 0.5093899595, "num_tokens": 2081, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.752012562644147, "lm_q2_score": 0.7853085909370422, "lm_q1q2_score": 0.5905619259370292}}
{"text": "module Verified.Algebra.Bool\n\nimport Classes.Verified\nimport Prelude.Algebra\n\n%default total\n\ninstance Semigroup Bool where\n -- Laziness intereferes with the types\n (<+>) = \\b1, b2 => b1 || b2\n\ninstance VerifiedSemigroup Bool where\n semigroupOpIsAssociative True _ _ = Refl\n semigroupOpIsAssociative False True _ = Refl\n semigroupOpIsAssociative False False True = Refl\n semigroupOpIsAssociative False False False = Refl\n\ninstance Monoid Bool where\n neutral = False\n\ninstance VerifiedMonoid Bool where\n monoidNeutralIsNeutralL True = Refl\n monoidNeutralIsNeutralL False = Refl\n monoidNeutralIsNeutralR r = Refl\n", "meta": {"hexsha": "8bd200cff5d0508a07d5f4ebd6e264ce06c9ecdc", "size": 621, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Verified/Algebra/Bool.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/Algebra/Bool.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/Algebra/Bool.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.84, "max_line_length": 51, "alphanum_fraction": 0.7906602254, "num_tokens": 173, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8918110396870287, "lm_q2_score": 0.6619228891883799, "lm_q1q2_score": 0.590310139999731}}
{"text": "module TypedContainers.Util.Filter\n\nimport Data.List\n\n%default total\n\npublic export\n0 filterCommutative' :\n {f : a -> Bool} -> {g : a -> Bool} -> (xxs : List a) -> (yys : List a)\n -> (yys = filter f (filter g xxs)) -> (yys = filter g (filter f xxs))\nfilterCommutative' [] yys p = p\nfilterCommutative' (x :: xs) yys p =\n case the (DPair Bool (g x ===)) $ MkDPair (g x) Refl of\n MkDPair True p0 => case the (DPair Bool (f x ===)) $ MkDPair (f x) Refl of\n MkDPair True p1 =>\n let p2 : (filter f (x :: filter g xs) = filter f (filter g (x :: xs))) = rewrite p0 in Refl in\n let p3 : (x :: filter f (filter g xs) = filter f (x :: filter g xs)) = rewrite p1 in Refl in\n let p3 : (x :: filter f (filter g xs) = filter f (filter g (x :: xs))) = trans p3 p2 in\n case yys of\n [] impossible\n y :: ys =>\n let (Refl) : (y :: ys = x :: filter f (filter g xs)) = trans p (sym p3) in\n let p4 = filterCommutative' {f, g} xs ys Refl in\n rewrite p1 in rewrite p0 in cong (x ::) p4\n MkDPair False p1 =>\n let p2 : (filter f (x :: filter g xs) = filter f (filter g (x :: xs))) = rewrite p0 in Refl in\n let p3 : (filter f (filter g xs) = filter f (x :: filter g xs)) = rewrite p1 in Refl in\n let p3 : (filter f (filter g xs) = filter f (filter g (x :: xs))) = trans p3 p2 in\n case yys of\n [] impossible\n y :: ys =>\n let p4 : (y :: ys = filter f (filter g xs)) = trans p (sym p3) in\n let p5 = filterCommutative' {f, g} xs (y :: ys) p4 in\n rewrite p1 in p5\n MkDPair False p0 =>\n let p2 : (filter f (filter g (x :: xs)) = filter f (filter g xs)) = rewrite p0 in Refl in\n let p3 : (yys = filter f (filter g xs)) = trans p p2 in\n let p4 = filterCommutative' {f, g} xs yys p3 in\n case the (DPair Bool (f x ===)) $ MkDPair (f x) Refl of\n MkDPair True p5 => rewrite p5 in rewrite p0 in p4\n MkDPair False p5 => rewrite p5 in p4\n\npublic export\n0 filterCommutative : (filter f (filter g l) = filter g (filter f l))\nfilterCommutative = filterCommutative' {f, g} l (filter f (filter g l)) Refl\n\n0 filterImplication' :\n {f : a -> Bool} -> {g : a -> Bool}\n -> ((x : a) -> (g x = True) -> (f x = True)) -> (xxs : List a) -> (yys : List a)\n -> (yys = filter f (filter g xxs)) -> (yys = filter g xxs)\nfilterImplication' p0 [] yys p1 = p1\nfilterImplication' p0 (x :: xs) yys p1 =\n case the (DPair Bool (g x ===)) $ MkDPair (g x) Refl of\n MkDPair True p2 =>\n let p3 : (filter f (filter g (x :: xs)) = filter f (x :: filter g xs)) = rewrite p2 in Refl in\n let p4 : (filter f (x :: filter g xs) = x :: filter f (filter g xs)) = rewrite (p0 x p2) in Refl in\n let p5 : (yys = x :: filter f (filter g xs)) = trans (trans p1 p3) p4 in\n let p6 : (filter f (filter g xs) = filter g xs) = filterImplication' {f, g} p0 xs (filter f (filter g xs)) Refl in\n let p7 : (yys = x :: filter g xs) = replace {p = \\p => yys === x :: p} p6 p5 in\n rewrite p2 in p7\n MkDPair False p2 =>\n let p3 : (filter f (filter g (x :: xs)) = filter f (filter g xs)) = rewrite p2 in Refl in\n let p5 : (yys = filter f (filter g xs)) = trans p1 p3 in\n let p6 : (filter f (filter g xs) = filter g xs) = filterImplication' {f, g} p0 xs (filter f (filter g xs)) Refl in\n let p7 : (yys = filter g xs) = replace {p = (yys ===)} p6 p5 in\n rewrite p2 in p7\n\npublic export\n0 filterImplication : ((x : a) -> (g x = True) -> (f x = True)) -> (filter f (filter g l) = filter g l)\nfilterImplication p = filterImplication' {f, g} p l (filter f (filter g l)) Refl\n\n0 filterExtensionality' : {f : a -> Bool} -> {g : a -> Bool} -> {p : (x : a) -> f x = g x} -> (l : List a) -> (filter f l = filter g l)\nfilterExtensionality' [] = Refl\nfilterExtensionality' (x :: xs) =\n let rec = filterExtensionality' {f, g, p} xs in\n case MkDPair (f x) Refl {p = (f x ===)} of\n MkDPair True p0 =>\n let p1 : (g x = True) = rewrite sym $ p x in p0 in\n rewrite p1 in\n rewrite p0 in\n rewrite rec in\n Refl\n MkDPair False p0 =>\n let p1 : (g x = False) = rewrite sym $ p x in p0 in\n rewrite p1 in\n rewrite p0 in\n rewrite rec in\n Refl\n\npublic export\n0 filterExtensionality : ((x : a) -> f x = g x) -> (filter f l = filter g l)\nfilterExtensionality p = filterExtensionality' {p} l\n", "meta": {"hexsha": "9d8d9ecfc761b3055bad8d36eb5bce3a6d95c39f", "size": 4394, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "TypedContainers/Util/Filter.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/Util/Filter.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/Util/Filter.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": 47.247311828, "max_line_length": 135, "alphanum_fraction": 0.5596267638, "num_tokens": 1546, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.7371581626286834, "lm_q1q2_score": 0.5902366450965356}}
{"text": "module QAOA\n\nimport Data.Nat\nimport Data.Vect\nimport Graph\nimport Lemmas\nimport Unitary\nimport Control.Linear.LIO\nimport QStateT\nimport Injection\nimport LinearTypes\nimport Complex\nimport System.Random\nimport QuantumOp\nimport RandomUtilities\n\n%default total\n\n||| Vanilla QAOA : we use QAOA with a vanilla optimisation procedure to solve MAXCUT.\n\n\n-------------------------QUANTUM CIRCUITS----------------------\n\n||| The unitary operator induced by the mixing hamiltonian.\n||| n -- the arity of the operator\n||| beta -- the rotation angle parameter\nmixingUnitary : (n : Nat) -> (beta : Double) -> Unitary n\nmixingUnitary n beta = tensorn n (RxGate beta)\n\n||| Helper function for costUnitary\n||| m -- number of vertices of the input subgraph\n||| n -- number of remaining edges between current vertex and the rest\n||| prf -- proof witness that the number of vertices does not exceed the arity of the operator\n||| gamma -- the rotation parameter\n||| edges -- vector of edges that the current vertex is connected to\n||| currentUnitary -- the currently constructed unitary operator\n||| output -- the final unitary operator\ncostUnitary' : {n : Nat} -> {m : Nat} -> {auto prf : n < m = True} -> \n (gamma : Double) -> (edges : Vect n Bool) -> (currentUnitary : Unitary m) -> Unitary m\ncostUnitary' _ [] currentUnitary = currentUnitary\ncostUnitary' {n = S k} gamma (False :: xs) currentUnitary =\n let proof1 = lemmaLTSuccLT k m \n in costUnitary' gamma xs currentUnitary\ncostUnitary' {n = S k} gamma (True :: xs) currentUnitary =\n let proof1 = lemmaCompLT0 m (S k)\n proof2 = lemmaLTSuccLT k m\n cx = CNOT 0 (S k) (IdGate {n = m})\n rzcx = P gamma (S k) cx\n rest = costUnitary' gamma xs currentUnitary\n in rest . cx . rzcx\n\n||| The unitary operator induced by the cost hamiltonian.\n||| n -- the number of vertices of the input graph\n||| graph -- the input graph\n||| gamma -- rotation parameter\n||| output -- the resulting unitary operator\ncostUnitary : {n : Nat} -> (graph: Graph n) -> (gamma : Double) -> Unitary n\ncostUnitary Empty _ = IdGate\ncostUnitary (AddVertex graph edges) gamma = \n let circuit = (IdGate {n = 1}) # (costUnitary graph gamma)\n proof1 = lemmaLTSucc n\n in costUnitary' gamma edges circuit\n\n||| The iterated cost and mixing unitaries for QAOA_p\n||| n -- the number of vertices of the graph\n||| p -- the \"p\" parameter of QAOA_p, i.e., the number of iterations of the mixing and cost unitaries\n||| betas -- list of rotation parameters for the mixing hamiltonians\n||| gammas -- list of rotation parameters for the cost hamilitonians\n||| graph -- the input graph\n||| output -- the overall unitary operator of QAOA_p\nQAOA_Unitary' : {n : Nat} ->\n (betas : Vect p Double) -> (gammas : Vect p Double) -> \n (graph: Graph n) ->\n Unitary n\nQAOA_Unitary' [] [] g = IdGate\nQAOA_Unitary' (beta :: betas) (gamma :: gammas) g = \n let circuit = QAOA_Unitary' betas gammas g \n in circuit . mixingUnitary n beta . costUnitary g gamma\n\n||| The overall unitary operator for QAOA_p\n||| n -- the number of vertices of the graph\n||| p -- the \"p\" parameter of QAOA_p, i.e., the number of iterations of the mixing and cost unitaries\n||| betas -- list of rotation parameters for the mixing hamiltonians\n||| gammas -- list of rotation parameters for the cost hamilitonians\n||| graph -- the input graph\n||| output -- the overall unitary operator of QAOA_p\nexport\nQAOA_Unitary : {n : Nat} ->\n (betas : Vect p Double) -> (gammas : Vect p Double) -> \n (graph: Graph n) ->\n Unitary n\nQAOA_Unitary betas gammas graph = (QAOA_Unitary' betas gammas graph) . (tensorn n HGate)\n\n\n-------------------------CLASSICAL PART------------------------\n\n||| The (probabilistic) classical optimisation procedure for QAOA.\n||| IO output allows us to use probabilistic optimisation procedures.\n||| Given all previously observed information, determine new rotation angles for the next QAOA run. \n||| Remark: we randomly generate the next rotation angles for simplicity.\n|||\n||| k -- number of previous iterations of the algorithm\n||| p -- \"p\" parameter for QAOA_p\n||| n -- number of vertices of the input graph\n||| graph -- the input graph\n||| previous_info -- previously used parameters and previously observed cuts from QAOA runs\n||| IO output -- new rotation angles for the next run of QAOA\nclassicalOptimisation : {p : Nat} ->\n (graph : Graph n) ->\n (previous_info : Vect k (Vect p Double, Vect p Double, Cut n)) -> \n IO (Vect p Double, Vect p Double)\nclassicalOptimisation g ys = do\n betas <- randomVect p\n gammas <- randomVect p\n pure (betas,gammas)\n\n\n-----------------------------QAOA------------------------------\n\n||| Helper function for QAOA\n||| \n||| n -- number of vertices of the input graph\n||| p -- the \"p\" parameter of QAOA_p\n||| k -- number of times we sample (the number of times we execute QAOA_p)\n||| graph -- input graph of the problem\n||| output -- all observed cuts and all rotation angles from all the runs of QAOA\nQAOA' : QuantumOp t =>\n {n : Nat} ->\n (k : Nat) -> (p : Nat) -> (graph : Graph n) ->\n IO (Vect k (Vect p Double, Vect p Double, Cut n))\nQAOA' 0 p graph = pure []\nQAOA' (S k) p graph = do\n previous_info <- QAOA' {t} k p graph \n (betas, gammas) <- classicalOptimisation graph previous_info\n let circuit = QAOA_Unitary betas gammas graph\n cut <- run (do\n qs <- newQubits {t} n\n qs <- applyUnitary qs circuit \n measureAll qs\n )\n pure $ (betas, gammas, cut) :: previous_info\n\n||| QAOA for the MAXCUT problem. Given an input graph, return the best observed cut after some number of iterations.\n||| \n||| n -- number of vertices of the input graph\n||| p -- the \"p\" parameter of QAOA_p\n||| k -- number of times we sample (the number of times we execute QAOA_p)\n||| graph -- input graph of the problem\n||| output -- best observed cut from the execution of the algorithm\nexport\nQAOA : QuantumOp t =>\n {n : Nat} ->\n (k : Nat) -> (p : Nat) -> Graph n ->\n IO (Cut n)\nQAOA k p graph = do\n res <- QAOA' {t} k p graph\n let cuts = map (\\(_, _, cut) => cut) res\n let (cut,size) = bestCut graph cuts\n pure cut\n", "meta": {"hexsha": "096777f9e6ae0ec4c1d57ed352d4064b6d63de97", "size": 6482, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "QAOA.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": "QAOA.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": "QAOA.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": 40.5125, "max_line_length": 116, "alphanum_fraction": 0.6294353595, "num_tokens": 1795, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267864276107, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.5900886522566089}}
{"text": "data ListLast : List a -> Type where\n Empty : ListLast []\n NonEmpty : (xs : List a) -> (x : a) -> ListLast (xs ++ [x])\n\nlistLast : (xs : List a) -> ListLast xs\nlistLast [] = Empty\nlistLast (x :: xs) = case listLast xs of\n Empty => NonEmpty [] x\n NonEmpty xs y => NonEmpty (x :: xs) y\n\ndescribe_list_end : List Int -> String\n\ndescribe_list_end input with (listLast input)\n describe_list_end [] | Empty = ?describe_list_end_rhs_1\n describe_list_end (xs ++ [x]) | (NonEmpty xs x) = ?describe_list_end_rhs_2\n", "meta": {"hexsha": "231eb44adec946efc47a4434645c3ce4e057c1c5", "size": 564, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/typedd-book/chapter10/DescribeList2.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": "Chapter10/DescribeList2.idr", "max_issues_repo_name": "gdevanla/TypeDD-Samples", "max_issues_repo_head_hexsha": "a5c08a13e6a6ec804171526aca10aae946588323", "max_issues_repo_licenses": ["MIT"], "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": "Chapter10/DescribeList2.idr", "max_forks_repo_name": "gdevanla/TypeDD-Samples", "max_forks_repo_head_hexsha": "a5c08a13e6a6ec804171526aca10aae946588323", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 41, "max_forks_repo_forks_event_min_datetime": "2017-03-19T11:01:54.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-10T05:30:22.000Z", "avg_line_length": 35.25, "max_line_length": 76, "alphanum_fraction": 0.5975177305, "num_tokens": 159, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8244619436290698, "lm_q2_score": 0.7154240018510025, "lm_q1q2_score": 0.5898398630849647}}
{"text": "> module Fraction.Fraction\n\n> import PNat.PNat\n\n> %default total\n> %access public export\n\n\n> ||| Fraction representation\n> Fraction : Type\n> Fraction = (Nat, PNat)\n", "meta": {"hexsha": "f5aabee7344ba142dcefd0f152177cd5114f22b7", "size": 164, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "Fraction/Fraction.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": "Fraction/Fraction.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": "Fraction/Fraction.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.6666666667, "max_line_length": 29, "alphanum_fraction": 0.7012195122, "num_tokens": 44, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8354835371034368, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.589671761151088}}
{"text": "module Struts\n\ndata Rat : Nat -> Nat -> Type where\n MkRat : (a : Nat) -> (b : Nat) -> Rat a b\n\nmultRat : Rat a b -> Rat c d -> Rat (a*c) (b*d)\nmultRat (MkRat a b) (MkRat c d) = MkRat (a*c) (b*d)\n\ndivRat : Rat a b -> Rat c d -> Rat (a*d) (b*c)\ndivRat (MkRat a b) (MkRat c d) = MkRat (a*d) (b*c)\n\naddRat : Rat a b -> Rat c d -> Rat (a*d + b*c) (b*d)\naddRat (MkRat a b) (MkRat c d) = MkRat (a*d + b*c) (b*d)\n\nsimplify : Rat a b -> Rat (divNat a (gcd a b)) (divNat b (gcd a b))\nsimplify (MkRat a b) = MkRat (divNat a (gcd a b)) (divNat b (gcd a b))\n\nfromNat : (n : Nat) -> Rat n 1\nfromNat n = MkRat n 1\n\ndata Pitch = A | B | C | D | E | F | G\n\ndata Note : (r : Rat a b) -> Type where\n MkNote : Pitch -> Note r\n\nquarter : Pitch -> Note (MkRat 1 4)\nquarter = MkNote\n\ndata NoteSequence : (r : Rat a b) -> Type where\n Empty : NoteSequence (fromNat 0)\n Append : Note s -> NoteSequence r -> NoteSequence (addRat s r)\n\ndata Measure : (r : Rat a b) -> Type where\n MkMeasure : NoteSequence r -> Measure r\n\nfin : NoteSequence (fromNat 0)\nfin = Empty\n\ninfixr 10 ~>\n\n(~>) : Note s -> NoteSequence r -> NoteSequence (addRat s r)\n(~>) = Append\n\nbeatMeasure : Measure (MkRat 1 4)\nbeatMeasure = MkMeasure (quarter C ~> fin)\n\n", "meta": {"hexsha": "6fec1d006ffdcb6ead3092f70faf170c953bf20d", "size": 1210, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Struts.idr", "max_stars_repo_name": "5outh/struts", "max_stars_repo_head_hexsha": "7bcd468541c09d31a8d16d48f9a0ac54557c5e20", "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": "Struts.idr", "max_issues_repo_name": "5outh/struts", "max_issues_repo_head_hexsha": "7bcd468541c09d31a8d16d48f9a0ac54557c5e20", "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": "Struts.idr", "max_forks_repo_name": "5outh/struts", "max_forks_repo_head_hexsha": "7bcd468541c09d31a8d16d48f9a0ac54557c5e20", "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.7446808511, "max_line_length": 70, "alphanum_fraction": 0.5909090909, "num_tokens": 480, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009596336303, "lm_q2_score": 0.6442250996557036, "lm_q1q2_score": 0.5894021618950743}}
{"text": "%hint\nmycong : (f : a -> b) -> x = y -> f x = f y\nmycong f Refl = Refl\n\nplusZ : (n : Nat) -> plus n Z = n\n\nplusS : (n : Nat) -> (m : Nat) -> plus n (S m) = S (plus n m)\n", "meta": {"hexsha": "30e0c447cf4bccced094063314c9ceca509022eb", "size": 169, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/interactive018/PlusPrf.idr", "max_stars_repo_name": "Qqwy/Idris2-Erlang", "max_stars_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "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/tests/idris2/interactive018/PlusPrf.idr", "max_issues_repo_name": "Qqwy/Idris2-Erlang", "max_issues_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "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/tests/idris2/interactive018/PlusPrf.idr", "max_forks_repo_name": "Qqwy/Idris2-Erlang", "max_forks_repo_head_hexsha": "945f9c12d315d73bfda2d441bc5f9f20696b5066", "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": 21.125, "max_line_length": 61, "alphanum_fraction": 0.4556213018, "num_tokens": 78, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8311430562234877, "lm_q2_score": 0.7090191460821871, "lm_q1q2_score": 0.5892963399957165}}
{"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 Elem' : a -> Vect k a -> Type where\n Here' : Elem' x (x :: xs)\n There' : (later : Elem' x xs) -> Elem' x (y :: xs)\n\nremoveElemPrf :\n (value : a) ->\n (xs : Vect (S n) a) ->\n (prf : Elem value xs) ->\n Vect n a\nremoveElemPrf value (value :: ys) Here = ys\nremoveElemPrf {n = Z} value (y :: []) (There later) = absurd later\nremoveElemPrf {n = (S k)} value (y :: ys) (There later) = y :: removeElemPrf value ys later\n\nremoveElem :\n (value : a) ->\n (xs : Vect (S n) a) ->\n {auto prf : Elem value xs} ->\n Vect n a\nremoveElem x xs {prf} = removeElemPrf x xs prf\n\nnotInTail : (notHere : (value = x) -> Void) -> (notThere : Elem value xs -> Void) -> Elem value (x :: xs) -> Void\nnotInTail notHere notThere Here = notHere Refl\nnotInTail notHere notThere (There later) = notThere later\n\nnotInNil : Elem value [] -> Void\nnotInNil Here impossible\nnotInNil (There _) impossible\n\nisYes : Dec a -> Bool\nisYes (Yes prf) = True\nisYes (No contra) = False\n\nisElem' : DecEq ty => (value : ty) -> (xs : Vect n ty) -> Dec (Elem value xs)\nisElem' value [] = No notInNil\nisElem' value (x :: xs) = case decEq value x of\n Yes Refl => Yes Here\n No notHere => case isElem' value xs of\n Yes prf => Yes (There prf)\n No notThere => No (notInTail notHere notThere)\n\ndata LElem : a -> List a -> Type where\n LHere : LElem a (a :: as)\n LThere : LElem a as -> LElem a (b :: as)\n\ndata Last : List a -> a -> Type where\n LOne : Last [value] value\n LCons : (prf : Last xs value) -> Last (x :: xs) value\n\nnoLast1 : (notLast : (x = value) -> Void) -> Last [x] value -> Void\nnoLast1 notLast LOne = notLast Refl\nnoLast1 _ (LCons LOne) impossible\nnoLast1 _ (LCons (LCons _)) impossible\n\nnoLast2 : (noLast : Last (y :: ys) value -> Void) -> Last (x :: (y :: ys)) value -> Void\nnoLast2 noLast (LCons prf) = noLast prf\n\nnoLast0 : Last [] value -> Void\nnoLast0 LOne impossible\nnoLast0 (LCons _) impossible\n\nisLast : DecEq a => (xs : List a) -> (value : a) -> Dec (Last xs value)\nisLast [] value = No noLast0\nisLast (x :: []) value = case decEq x value of\n Yes Refl => Yes LOne\n No notLast => No (noLast1 notLast)\nisLast (x :: y :: ys) value = case isLast (y :: ys) value of\n Yes prf => Yes (LCons prf)\n No noLast => No (noLast2 noLast)\n\nmain : IO ()\nmain = do\n printLn $ removeElem 3 [1,2,3]\n printLn $ isYes $ isElem' 3 [1,2,3]\n printLn $ isYes $ isElem' 10 [1,2,3,4,5,6,7,8,9]\n-- printLn $ isYes $ isLast 10 [1,2,3,4,5,6,7,8,9] -- Idris bug: Infinite loop\n", "meta": {"hexsha": "621282d5638bb94d6b53234cef29c1c0dfa74595", "size": 2884, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "test/tdd/chapter09/01_RemoveElem.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/chapter09/01_RemoveElem.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/chapter09/01_RemoveElem.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": 32.7727272727, "max_line_length": 113, "alphanum_fraction": 0.6366158114, "num_tokens": 1006, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929104825006, "lm_q2_score": 0.7549149978955811, "lm_q1q2_score": 0.5888283463754652}}
{"text": "import public Lightyear\nimport public Lightyear.Char\nimport public Lightyear.Strings\n\nName : Type\nName = String\n\nshowParen : String -> String\nshowParen x = \"(\" ++ x ++ \")\"\n\ndata Tm\n = Var Name -- x\n | Lam Name Tm -- \\x. t\n | App Tm Tm -- t u\n | Let Name Tm Tm -- let x = t in u\nShow Tm where\n show (Var str) = str\n show (Lam x t) = showParen (\"λ\" ++ x ++ \".\" ++ show t)\n show (App t u) = showParen (\"\" ++ show t ++ \" \" ++ show u)\n show (Let str tm1 tm2) = showParen (\"Let \" ++ str ++ \" = \" ++ show tm1 ++ \" in \" ++ show tm2)\n\n-- parsing\n\nkeyword : String -> Bool\nkeyword x = x == \"λ\" || x == \"in\" || x == \"let\"\n\npIdent' : Parser Name\npIdent' = do f <- satisfy (isAlphaNum)\n i <- many (satisfy isAlphaNum)\n pure (pack (f :: i)) <* spaces\n\npIdent : Parser Name\npIdent = do\n str <- pIdent'\n guard (not (keyword str))\n pure str\n\npBind : Parser Name\npBind = pIdent <|> (token \"_\" *> pure \"_\")\n\nmutual\n pAtom : Parser Tm\n pAtom = (Var <$> pIdent) <|> parens pTm -- what's `<$>` doing here?\n\n pTm : Parser Tm\n pTm = pLet <|>| pLam <|>| pSpine\n\n pLam : Parser Tm\n pLam = do\n char 'λ' <|> char '\\\\'\n xs <- some pBind\n token \".\"\n t <- pTm\n pure (foldr Lam t xs)\n\n pLet : Parser Tm\n pLet = do\n token \"let\"\n x <- pBind\n token \"=\"\n t <- pTm\n token \"in\"\n u <- pTm\n pure $ Let x t u\n\n pSpine : Parser Tm\n pSpine = foldl1 App <$> some pAtom\n\n-- evaluation\n\ndata Val\n = VVar Name\n | VApp Val Val\n | VLam Name (Val -> Val)\n\nEnv : Type\nEnv = List (Name, Maybe Val)\n\nfresh : Env -> Name -> Name\nfresh env \"_\" = \"_\"\nfresh env x = case lookup x env of\n Nothing => x\n (Just _) => fresh env (x ++ \"'\")\n\neval : Env -> Tm -> Val\neval env (Var x) = let findX = lookup x env in\n (case findX of\n Nothing => VVar x\n (Just x') => (case x' of\n Nothing => VVar x\n (Just x'') => x''))\neval env (App t u) = let evalT = eval env t\n evalU = eval env u\n in\n (case evalT of\n (VLam _ f) => f evalU\n _ => VApp evalT evalU)\neval env (Lam x t) = VLam x (\\u => eval ((x, Just u)::env) t)\neval env (Let x t u) = let nextEnv = Just (eval env t) in\n eval ((x, nextEnv)::env) u\n\nquote : Env -> Val -> Tm\nquote env (VVar x) = Var x\nquote env (VApp t u) = App (quote env t) (quote env u)\nquote env (VLam x t) = let freshX = fresh env x in\n Lam freshX (quote ((x, Nothing)::env) (t (VVar x)))\nnf : Env -> Tm -> Tm\nnf env = let qe = quote env\n ee = eval env in\n qe . ee\n\ntest : Maybe Tm\ntest = let parsed = (Lightyear.Strings.parse (pTm) \"let five = \\\\s z. s (s (s (s (s z)))) in let add = \\\\a b s z. a s (b s z) in let mul = \\\\a b s z. a (b s) z in let ten = add five five in let hundred = mul ten ten in let thousand = mul ten hundred in let tenthousand = mul ten thousand in tenthousand\") in\n (case parsed of\n (Left l) => Nothing\n (Right r) => Just (nf [] r))\n\ntest2 : Maybe Tm\ntest2 = let parsed = (Lightyear.Strings.parse (pTm) \"let true = (\\\\x y. x) in let false = (\\\\x y. y) in let and = (\\\\x y. (x (y true false) false)) in let or = (\\\\x y. (x true (y true false))) in or false true\") in\n (case parsed of\n (Left l) => Nothing\n (Right r) => Just (nf [] r))\n", "meta": {"hexsha": "647af710310044728e395673244ded3bf6f71da1", "size": 3626, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "lambda-calc/Lambda.idr", "max_stars_repo_name": "alexhumphreys/pl-playground", "max_stars_repo_head_hexsha": "da90cc3527e0ff3a7effd1f5dde5437b47ac1170", "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": "lambda-calc/Lambda.idr", "max_issues_repo_name": "alexhumphreys/pl-playground", "max_issues_repo_head_hexsha": "da90cc3527e0ff3a7effd1f5dde5437b47ac1170", "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": "lambda-calc/Lambda.idr", "max_forks_repo_name": "alexhumphreys/pl-playground", "max_forks_repo_head_hexsha": "da90cc3527e0ff3a7effd1f5dde5437b47ac1170", "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": 29.4796747967, "max_line_length": 307, "alphanum_fraction": 0.4864864865, "num_tokens": 1131, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267118026095991, "lm_q2_score": 0.7122321903471563, "lm_q1q2_score": 0.5888107579584807}}
{"text": "module Types.Inclusion\n\nimport Syntax.PreorderReasoning\nimport Control.Isomorphism\n\n%default total\n\n-- An inclusion from a to b\ndata Inclusion : (a, b : Type) -> Type where\n Include : (upcast : a -> b) ->\n (downcast : b -> Maybe a) ->\n (upThenDown : (x : a) -> downcast (upcast x) = Just x) ->\n (downThenUp : (y : b) -> maybe () (\\x => upcast x = y) (downcast y)) ->\n Inclusion a b\n\nincludeRefl : Inclusion a a\nincludeRefl = Include id Just (\\x => Refl) (\\y => Refl)\n\n\nincludeTrans : Inclusion a b -> Inclusion b c -> Inclusion a c\nincludeTrans {a} {b} {c} (Include u d ud du) (Include u' d' ud' du') =\n Include (\\x => u' (u x))\n (\\y => (d' y) >>= d)\n ok1\n ok2\n\n where ok1 : (x : a) -> (d' (u' (u x))) >>= d = Just x\n ok1 x = ((d' (u' (u x))) >>= d) ={ cong {f=(>>= d)} (ud' (u x)) }=\n ((Just (u x)) >>= d) ={ Refl }=\n (d (u x)) ={ ud x }=\n (Just x) QED\n\n ok2 : (y : c) -> maybe () (\\x => u' (u x) = y) ((d' y) >>= d)\n ok2 y = ok2' (d' y) (du' y) -- Do the first case analysis, but keep the proof\n where ok2' : (z : Maybe b) ->\n maybe () (\\x => u' x = y) z ->\n maybe () (\\x => u' (u x) = y) (z >>= d)\n ok2' Nothing prf = ()\n ok2' (Just x) prf = ok2'' (d x) (du x) -- second analysis, keep proof\n where ok2'' : (z : Maybe a) ->\n maybe () (\\w => u w = x) z ->\n maybe (the Type ()) (\\x1 => u' (u x1) = y) z\n ok2'' Nothing prf2 = ()\n ok2'' (Just v) prf2 = (u' (u v)) ={ cong prf2 }=\n (u' x) ={ prf }=\n y QED\n\n-- Enable preorder reasoning syntax over inclusions\nqed : (a : Type) -> Inclusion a a\nqed a = includeRefl\n\nstep : (a : Type) -> Inclusion a b -> Inclusion b c -> Inclusion a c\nstep a incl1 incl2 = includeTrans incl1 incl2\n\n-- Every isomorphism gives an inclusion mapping\nincludeIso : Iso a b -> Inclusion a b\nincludeIso {a} {b} (MkIso to from toFrom fromTo) =\n Include to (\\x => Just (from x)) ok1 ok2\n where ok1 : (x : a) -> (Just (from (to x)) = Just x)\n ok1 x = rewrite fromTo x in Refl -- workaround for de Bruijn index bug\n ok2 : (y : b) -> to (from y) = y\n ok2 y = rewrite toFrom y in Refl -- workaround for de Bruijn index bug\n\ncastUp : Inclusion a b -> a -> b\ncastUp (Include up _ _ _) = up\n\ncastDown : Inclusion a b -> b -> Maybe a\ncastDown (Include _ down _ _) = down\n", "meta": {"hexsha": "57a576a72ecf708e73199cfbcb44630747941e63", "size": 2741, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Types/Inclusion.idr", "max_stars_repo_name": "david-christiansen/idris-utils", "max_stars_repo_head_hexsha": "f828b9fbc5b2df754eebfbfcb1b2ead86f16352f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2016-10-07T06:22:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T21:15:29.000Z", "max_issues_repo_path": "Types/Inclusion.idr", "max_issues_repo_name": "david-christiansen/idris-utils", "max_issues_repo_head_hexsha": "f828b9fbc5b2df754eebfbfcb1b2ead86f16352f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2015-01-30T23:21:51.000Z", "max_issues_repo_issues_event_max_datetime": "2015-01-31T19:05:05.000Z", "max_forks_repo_path": "Types/Inclusion.idr", "max_forks_repo_name": "david-christiansen/idris-utils", "max_forks_repo_head_hexsha": "f828b9fbc5b2df754eebfbfcb1b2ead86f16352f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2015-01-30T17:59:38.000Z", "max_forks_repo_forks_event_max_datetime": "2015-01-30T17:59:38.000Z", "avg_line_length": 39.7246376812, "max_line_length": 87, "alphanum_fraction": 0.4502006567, "num_tokens": 840, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117940706734, "lm_q2_score": 0.712232184238947, "lm_q1q2_score": 0.5888107468270543}}
{"text": "import Data.List\n\ndata SnocList : List a -> Type where\n Empty : SnocList []\n Snoc : (x, xs : _) -> (rec : SnocList xs) -> SnocList (xs ++ [x])\n\nsnocListHelp : {input : _} ->\n (snoc : SnocList input) -> (rest : List a) -> SnocList (input ++ rest)\nsnocListHelp snoc [] = rewrite appendNilRightNeutral input in snoc\nsnocListHelp snoc (x :: xs)\n = rewrite appendAssociative input [x] xs in\n snocListHelp (Snoc x input snoc) xs\n\nsnocList : (xs : List a) -> SnocList xs\nsnocList xs = snocListHelp Empty xs\n\nmy_reverse_help : (input : List a) -> SnocList input -> List a\nmy_reverse_help [] Empty = []\nmy_reverse_help (xs ++ [x]) (Snoc x xs rec) = x :: my_reverse_help xs rec\n\nmy_reverse1 : List a -> List a\nmy_reverse1 input = my_reverse_help input (snocList input)\n\nmy_reverse : List a -> List a\nmy_reverse input with (snocList input)\n my_reverse [] | Empty = []\n my_reverse (xs ++ [x]) | (Snoc x xs rec) = x :: my_reverse xs | rec\n", "meta": {"hexsha": "e67b713bdafcc3ebe08fdc4cb40c965d5a75b246", "size": 966, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/typedd-book/chapter10/SnocList.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/typedd-book/chapter10/SnocList.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/typedd-book/chapter10/SnocList.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": 34.5, "max_line_length": 85, "alphanum_fraction": 0.6459627329, "num_tokens": 302, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199673867852, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.5884532141972307}}
{"text": "module Common.Abbrev\n\n%default total\n%access public export\n\nBinop : Type -> Type\nBinop s = s -> s -> s\n\nBinrel : Type -> Type\nBinrel s = s -> s -> Type\n\nOuterBinop : {index : Type} -> (f : index -> Type) -> (a,b,c : index) -> Type\nOuterBinop f a b c = f a -> f b -> f c \n\ninfixl 5 ===\ninfixl 5 @==\n\n||| associative infix syntax for `trans`\n(===) : a = b -> b = c -> a = c\n(===) Refl Refl = Refl\n\n(@==) : a = b -> a = c -> b = c\n(@==) Refl Refl = Refl\n", "meta": {"hexsha": "0027185b9b65332e889234d4bb11a6e19337cb9d", "size": 451, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Common/Abbrev.idr", "max_stars_repo_name": "jeroennoels/verified-algebra", "max_stars_repo_head_hexsha": "85dfd88fecaf32bd20de72923d2d10de59d8b859", "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/Common/Abbrev.idr", "max_issues_repo_name": "jeroennoels/verified-algebra", "max_issues_repo_head_hexsha": "85dfd88fecaf32bd20de72923d2d10de59d8b859", "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/Common/Abbrev.idr", "max_forks_repo_name": "jeroennoels/verified-algebra", "max_forks_repo_head_hexsha": "85dfd88fecaf32bd20de72923d2d10de59d8b859", "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": 18.7916666667, "max_line_length": 77, "alphanum_fraction": 0.5277161863, "num_tokens": 172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891305219505, "lm_q2_score": 0.7154239897159439, "lm_q1q2_score": 0.5882138280590968}}
{"text": "> module Math\n> import Data.Vect\n> import Data.HVect\n> import Data.List\n> import Data.Fin\n\nWe take some tricks from https://boxbase.org/entries/2019/sep/16/grabbag-of-idris-tricks/ and http://firsov.ee/finset/finset.pdf.\n\nUse Pauli group as small example:\n\n> data PauliGroup : Type where\n> X : PauliGroup\n> Y : PauliGroup\n> Zp : PauliGroup\n> I : PauliGroup\n\nWe provide a complete list of PauliGroup elements:\n\n> listPauli : List PauliGroup\n> listPauli = [X,Y,Zp,I]\n\n> allPauli : (x: PauliGroup) -> Data.List.Elem x Math.listPauli\n> allPauli X = Here\n> allPauli Y = There Here\n> allPauli Zp = There (There Here)\n> allPauli I = There (There (There Here))\n\n> xIsNotY : (X = Y) -> Void\n> xIsNotY Refl impossible\n> xIsNotZ : (X = Zp) -> Void\n> xIsNotZ Refl impossible\n> xIsNotI : (X = I) -> Void\n> xIsNotI Refl impossible\n> yIsNotZ : (Y = Zp) -> Void\n> yIsNotZ Refl impossible\n> yIsNotI : (Y = I) -> Void\n> yIsNotI Refl impossible\n> zIsNotI : (Zp = I) -> Void\n> zIsNotI Refl impossible\n\n\n> DecEq PauliGroup where\n> decEq X X = Yes Refl\n> decEq X Y = No xIsNotY\n> decEq X Zp = No xIsNotZ\n> decEq X I = No xIsNotI\n> decEq Y X = No (\\c => xIsNotY (sym c))\n> decEq Y Y = Yes Refl\n> decEq Y Zp = No yIsNotZ\n> decEq Y I = No yIsNotI\n> decEq Zp X = No (\\c => xIsNotZ (sym c))\n> decEq Zp Y = No (\\c => yIsNotZ (sym c))\n> decEq Zp Zp = Yes Refl\n> decEq Zp I = No zIsNotI\n> decEq I X = No (\\c => xIsNotI (sym c))\n> decEq I Y = No (\\c => yIsNotI (sym c))\n> decEq I Zp = No (\\c => zIsNotI (sym c))\n> decEq I I = Yes Refl\n\nAnd we give the group structure:\n\n> multPauli : PauliGroup -> PauliGroup -> PauliGroup\n> multPauli X X = I\n> multPauli X Y = Zp\n> multPauli X Zp = Y\n> multPauli X I = X\n> multPauli Y X = Zp\n> multPauli Y Y = I\n> multPauli Y Zp = X\n> multPauli Y I = Y\n> multPauli Zp X = Y\n> multPauli Zp Y = X\n> multPauli Zp Zp = I\n> multPauli Zp I = Zp\n> multPauli I X = X\n> multPauli I Y = Y\n> multPauli I Zp = Zp\n> multPauli I I = I\n\n> commPauli : (x:PauliGroup) -> (y:PauliGroup) -> (multPauli x y = multPauli y x)\n> commPauli X X = Refl\n> commPauli X Y = Refl\n> commPauli X Zp = Refl\n> commPauli X I = Refl\n> commPauli Y X = Refl\n> commPauli Y Y = Refl\n> commPauli Y Zp = Refl\n> commPauli Y I = Refl\n> commPauli Zp X = Refl\n> commPauli Zp Y = Refl\n> commPauli Zp Zp = Refl\n> commPauli Zp I = Refl\n> commPauli I X = Refl\n> commPauli I Y = Refl\n> commPauli I Zp = Refl\n> commPauli I I = Refl\n\nObviously there are a number of shortcomings with this approach.... and associativity\nwould take 64 lines to prove...\n\n> Injective : {t,u:Type} -> (t -> u) -> Type\n> Injective f {t} = (x,y:t) -> (f x = f y) -> (x = y)\n\n> Surjective : {t,u:Type} -> (t -> u) -> Type\n> Surjective f {t} {u} = (y:u) -> (x:t ** f x = y)\n\n> getInverse : {t,u:Type} -> {func: t -> u} -> (Injective func) -> (Surjective func) -> (u -> t)\n> getInverse {t} {u} {func} inj surj = \\y => fst (surj y)\n\n> Bijective : {t,u : Type} -> (t -> u) -> Type\n> Bijective f {t} {u} = ?bij\n\nProofs that a list contain all possible elements of a type:\n\n> All : {t : Type} -> List t -> Type \n> All xs {t} = (x:t) -> Elem x xs\n\nGiven a type t and a proof of t, it is a contradiction to have a proof that the\nempty list contains all elements of t.\n\n> allNotEmpty : All {t} [] -> t -> Void\n> allNotEmpty f x = absurd (f x)\n\n> voidEmptyAll : Uninhabited t => All {t} []\n> voidEmptyAll = \\c => absurd c\n\nDecidable list membership:\n\n> DecIn : (t: Type) -> Type\n> DecIn t = (x:t) -> (xs : List t) -> Dec (Elem x xs)\n\nDecidable equality and decidable list membership are equivalent:\n\n> decInToDeqEq : DecIn t -> (x:t) -> (y:t) -> Dec (x = y)\n> decInToDeqEq f x y = case (f x [y]) of\n> Yes Here => Yes Refl\n> No contra => No (\\eq => contra (rewrite eq in Here))\n\nLittle helper lemmas:\n\n> matchingSingleton : Data.List.Elem x [y] -> (x = y)\n> matchingSingleton Here = Refl\n> matchingSingleton (There later) impossible\n\n> deqEqToDeqIn : DecEq t => DecIn t\n> deqEqToDeqIn x [] = No absurd\n> deqEqToDeqIn x (y::ys) with (deqEqToDeqIn x ys) \n> deqEqToDeqIn x (y::ys) | No notLater = case decEq x y of\n> Yes Refl => Yes Here\n> No contra => No (\\later => \n> case later of\n> Here => contra (matchingSingleton Here)\n> (There t) => notLater t)\n> deqEqToDeqIn x (y::ys) | Yes later = Yes (There later)\n\n\nProof that a given type is a \"mere proposition\" (i.e. it only has one element)\n\n> Prop : (t:Type) -> Type\n> Prop t = (p1:t) -> (p2:t) -> (p1=p2)\n\nWe also have a notion of a List with no duplicates:\n\n> NoDupes : {t:Type} -> List t -> Type\n> NoDupes {t} xs = (x:t) -> Prop (Elem x xs)\n\nSome trivial helper lemmas:\n\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> voidsAreEquivalent : {t: Type} -> (t -> Void) -> (a:t) -> (b:t) -> (a=b)\n> voidsAreEquivalent f a b = void (f a)\n\n> sameTheresLemma : {a: Data.List.Elem x xs} -> (There a = There a)\n> sameTheresLemma = Refl\n\nTo avoid an awkward workaround with Void types, we force the caller to prove that\nthe type isn't void by providing some item. This might need some work...\n\n> deqEqToAllIncomplete : DecEq t => (xs:List t) -> t -> Dec (All xs)\n> deqEqToAllIncomplete [] someItem = No (\\c => allNotEmpty c someItem)\n> deqEqToAllIncomplete (x :: xs) someitem = Yes (\\c =>\n> case (decEq x c) of\n> Yes pf => rewrite pf in Here\n> No contra => ?newh2)\n\nAfter some reflection, I don't think this will work. We need to know *ahead of time*\nthat All {t} [xs] exists. This method will always fail to converge for Nats.\n\n> thereLemma1 : {a: Data.List.Elem x xs} -> {b : Data.List.Elem x xs} -> (a = b) -> There a = There b\n> thereLemma1 {a = Here} {b = Here} Refl = Refl\n> thereLemma1 {a = Here} {b = (There _)} Refl impossible\n> thereLemma1 {a = (There _)} {b = Here} Refl impossible\n> thereLemma1 {a = (There x)} {b = (There x)} Refl = Refl\n\n> thereLemma2 : {a: Data.List.Elem x xs} -> {b : Data.List.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\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 = absurd (notIn later)\n> consNoDupes {x = y} noDupesSublist notIn y (There later) Here | Yes pf = absurd (notIn later)\n> consNoDupes {x = x} noDupesSublist notIn y (There later) (There z) | Yes pf = absurd (notIn (rewrite pf in later)) --rewrite (noDupesSublist y later z) in Refl\n> consNoDupes {x = y} noDupesSublist notIn y Here Here | No contra = Refl\n> consNoDupes {x = y} noDupesSublist notIn y Here (There later) | No contra = absurd (notIn later)\n> consNoDupes {x = y} noDupesSublist notIn y (There later) Here | No contra = absurd (notIn later)\n> consNoDupes {x = x} noDupesSublist notIn y (There later) (There z) | No contra = let ndupes = (noDupesSublist y later z) in thereLemma1 ndupes\n\n\n> dupeCons : NoDupes (x :: xs) -> NoDupes xs\n> dupeCons dupeBiglist item pf1 pf2 = thereLemma2 (dupeBiglist item (There pf1) (There pf2))\n\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\nIf P is a decidable proposition, we can quotient P by the total equivalence relation\nand get a \"squashed\" type {what is this relation?}\n\n> squash : {p:Type} -> Dec p -> Type\n> squash (Yes _) = Unit\n> squash (No _) = Void\n\nAn example: Elem x [x,y,x] is decidable:\n\n> exSquash1 : Dec (Data.List.Elem X [X,Y,X])\n> exSquash1 = Yes Here\n\n> exSquash2 : Dec (Data.List.Elem X [X,Y,X])\n> exSquash2 = Yes (There (There Here))\n\nBoth \"squash\" to Unit. Note that any two squashed values are trivially equal:\n\n> propSquash : {p: Type} -> (d : Dec p) -> Prop (squash d)\n> propSquash (Yes prf) () () = Refl\n> propSquash (No contra) v1 _ = absurd v1\n\n> fromSquash : {p:Type} -> (d : Dec p) -> squash d -> p\n> fromSquash (Yes prf) () = prf\n\nmakeAllFin : (k:Nat) -> (xs:(List (Fin (S k))) ** All (Fin (S k)) xs)\nmakeAllFin Z = ([FZ] ** (IsAll (\\x => Here)))\n\nKuratowski finiteness:\n\n> Listable : (t : Type) -> Type\n> Listable t = (xs ** (All {t} xs))\n\nAn alternative idea is to require a surjection Fin n to t for some Nat n:\n\n> FinSurjective : (t: Type) -> Type\n> FinSurjective ty = (n:Nat ** (fromFin : (Fin n -> ty) ** (Surjective fromFin)))\n\nThese notions are equivalent. We need some helper lemmas... it is quite likely \nthat these can be cleaned up considerably...\n\n> getIndexOfElem : Data.List.Elem x xs -> Fin (length xs)\n> getIndexOfElem Here = FZ\n> getIndexOfElem (There later) = FS (getIndexOfElem later)\n\n> getIndexFromAll : All {t} xs -> t -> Fin (length xs)\n> getIndexFromAll {xs = []} pf x = absurd (pf x)\n> getIndexFromAll {xs = (y :: xs)} pf x = getIndexOfElem (pf x)\n\n> finIndexList : (l:List t) -> Fin (length l) -> t\n> finIndexList [] _ impossible\n> finIndexList (x :: _) FZ = x\n> finIndexList (_ :: xs) (FS y) = finIndexList xs y\n\n> getIndexOfElemLemma : (pf : Data.List.Elem x xs) -> finIndexList xs (getIndexOfElem pf) = x\n> getIndexOfElemLemma {xs = (x :: ys)} Here = Refl\n> getIndexOfElemLemma {xs = (y :: ys)} (There later) = getIndexOfElemLemma later\n\n> getIndexOfAllLemma : (pf : All {t} xs) -> (x : t) -> finIndexList xs (getIndexFromAll pf x) = x\n> getIndexOfAllLemma {xs} pf x with (pf x)\n> getIndexOfAllLemma {xs= x :: ys} pf x | Here = getIndexOfElemLemma (pf x)\n> getIndexOfAllLemma {xs= y :: ys} pf x | (There later) = getIndexOfElemLemma (pf x)\n\n> finIndexListSurjectiveIfAll : All {t} xs -> Surjective (finIndexList xs)\n> finIndexListSurjectiveIfAll {xs} pf = \\y => ((getIndexFromAll pf y) ** (getIndexOfAllLemma pf y))\n\n> indexIntoAll : All {t} xs -> (f : (Fin (length xs) -> t) ** Surjective f)\n> indexIntoAll {xs} pf = ((finIndexList xs) ** (finIndexListSurjectiveIfAll pf))\n\n> natToListFin : (n : Nat) -> List (Fin n)\n> natToListFin Z = []\n> natToListFin (S n) = (the (Fin (S n)) last) :: (map weaken (natToListFin n))\n\n> lastFinLemma : {n: Nat} -> (((FS k) = last {n=n}) -> Void) -> ((k = last {n=n}) -> Void)\n> lastFinLemma {n = Z} {k=_} _ impossible\n> lastFinLemma {n = (S Z)} {k = FZ} contra = absurd (contra Refl)\n> lastFinLemma {n = (S (S k))} {k = FZ} contra = ?lastFinLemma_rhs_4\n> lastFinLemma {n = (S j)} {k = (FS x)} contra = ?lastFinLemma_rhs_3\n\n lastFinLemma {n = Z} {k = FZ} _ impossible\n lastFinLemma {n = Z} {k = (FS _)} _ impossible\n\n\n> safeStrengthen : (f : Fin (S n)) -> (contra : (f = last {n=n}) -> Void) -> Fin n\n> safeStrengthen {n=Z} FZ contra = absurd (contra Refl)\n> safeStrengthen {n=(S k)} FZ contra = FZ\n> safeStrengthen {n=(S k)} (FS x) contra = ?ssh_2\n\n> natToListFinIsAll : (n : Nat) -> (All (natToListFin n))\n> natToListFinIsAll Z = voidEmptyAll\n> natToListFinIsAll (S n) = \\f => \n> case (decEq (the (Fin (S n)) last) f) of\n> Yes pf => rewrite pf in Here\n> No _ => ?newhole -- There (natToListFinIsAll n (safeStrengthen f))\n\nnatToListFinIsAll (S Z) = (\\FZ => Here)\n\n\n> getAllFins : (n : Nat) -> (xs : (List (Fin n)) ** All xs)\n> getAllFins n = ((natToListFin n) ** (natToListFinIsAll n))\n\n getAllFins (S k) = ((getAllFinsInner (S k)) ** )\n\n> listableIsFinSurjective : Listable t -> FinSurjective t\n> listableIsFinSurjective (xs ** pf) = ((length xs) ** (indexIntoAll pf))\n\n> finSurjectiveToList : FinSurjective t -> List t\n> finSurjectiveToList (bd ** (surj ** pf)) = map surj (fst (getAllFins bd))\n\n\n> finSurjectiveIsListable : FinSurjective t -> Listable t\n> finSurjectiveIsListable (bound ** (surj ** pf)) = ?finSurjectiveIsListable_rhs_2\n\n> contrapositive : (a -> b) -> Not b -> Not a\n> contrapositive f nb a = nb (f a)\n\nmakeAllFin (S k) = ?makeAllFin_rhs_2\n\n> interface Countable t where\n> FromNat : Nat -> t\n> ToNat : t -> Nat\n\n> Countable Nat where\n> FromNat = id\n> ToNat = id\n\nAn $n$-place relation on a collection of sets $S_1, S_2,\\dots,S_n$ is a set $R\\subset \nS_1 \\times S_2 \\times \\dots \\times S_n$. We say $s_1\\in S_1,s_2\\in S_2,\\dots, s_n\\in S_n$ \nare related by $R$ if $(s_1,s_2,\\dots,s_n)\\in R$.\n\n> NaryRelation : Vect n Type -> Type\n> NaryRelation xs = List (HVect xs) -- for our purposes it is fine to use lists instead of sets\n\n> BinaryRelation : Vect 2 Type -> Type\n> BinaryRelation = NaryRelation\n\n> domain : BinaryRelation [xt,yt] -> List yt\n> domain [] = []\n> domain ([x,y] :: xs) = y :: (domain xs)\n\n> codomain : BinaryRelation [xt,yt] -> List xt\n> codomain [] = []\n> codomain ([x,y] :: xs) = x :: (codomain xs)\n\n> data PartialFunction : BinaryRelation [xy,yt] -> Type where\n> ", "meta": {"hexsha": "3931f213015a40b00dc4c6d05ab92ac385b868f5", "size": 13476, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "TaPL1/Math.lidr", "max_stars_repo_name": "nicklecompte/CSLearning", "max_stars_repo_head_hexsha": "34fadc2d36068016cab66a4cc0e57c933f21c300", "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": "TaPL1/Math.lidr", "max_issues_repo_name": "nicklecompte/CSLearning", "max_issues_repo_head_hexsha": "34fadc2d36068016cab66a4cc0e57c933f21c300", "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": "TaPL1/Math.lidr", "max_forks_repo_name": "nicklecompte/CSLearning", "max_forks_repo_head_hexsha": "34fadc2d36068016cab66a4cc0e57c933f21c300", "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": 35.7453580902, "max_line_length": 163, "alphanum_fraction": 0.6358711784, "num_tokens": 4808, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289388083214155, "lm_q2_score": 0.7090191214879991, "lm_q1q2_score": 0.5877334656433589}}
{"text": "module Main\n\nimport Data.Vect\n\n%default total\n\ndata PowerSource = Petrol | Pedal\n\ndata Vehicle : PowerSource -> Type where\n Bicycle : Vehicle Pedal\n Car : (fuel : Nat) -> Vehicle Petrol\n Bus : (fuel : Nat) -> Vehicle Petrol\n\nwheels : Vehicle power -> Nat\nwheels Bicycle = 2\nwheels (Car _) = 4\nwheels (Bus _) = 4\n\nrefuel : Vehicle Petrol -> Vehicle Petrol\nrefuel (Car fuel) = Car 100\nrefuel (Bus _) = Bus 200\n\nappend : Vect n elem -> Vect m elem -> Vect (n + m) elem\nappend [] ys = ys\nappend (x :: xs) ys = x :: append xs ys\n\nzip' : Vect n a -> Vect n b -> Vect n (a , b)\nzip' [] [] = []\nzip' (x :: xs) (y :: ys) = (x, y) :: zip' xs ys\n\ntryIndex : Integer -> Vect n a -> Maybe a\ntryIndex {n} x l = case integerToFin x n of\n Nothing => Nothing\n Just f => Just (index f l)\n\nvectTake : (m : Fin n) -> Vect n a -> Vect (finToNat m) a\nvectTake FZ (x :: xs) = []\nvectTake (FS y) (x :: xs) = x :: vectTake y xs\n\nsumEntries : Num a => (m : Fin n) -> Vect n a -> Vect n a -> a\nsumEntries FZ (x :: xs) (y :: ys) = (x + y)\nsumEntries (FS x) (y :: xs) (z :: ys) = (sumEntries x xs ys)\n\nsumEntries' : Num a => (pos : Integer) -> Vect n a -> Vect n a -> Maybe a\nsumEntries' {n} pos l1 l2 = case integerToFin pos n of\n Nothing => Nothing\n Just f => Just ((index f l1) + (index f l2))\n\nmain : IO ()\nmain = putStrLn (cast 'x')\n", "meta": {"hexsha": "0215c85268cf3f13eacac6ada697eb8375f4bfc7", "size": 1411, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "lear01/lear01.idr", "max_stars_repo_name": "avatar29A/idris-learn", "max_stars_repo_head_hexsha": "8441cc5ccfbafa1670d88f55246f2bb52117cb48", "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": "lear01/lear01.idr", "max_issues_repo_name": "avatar29A/idris-learn", "max_issues_repo_head_hexsha": "8441cc5ccfbafa1670d88f55246f2bb52117cb48", "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": "lear01/lear01.idr", "max_forks_repo_name": "avatar29A/idris-learn", "max_forks_repo_head_hexsha": "8441cc5ccfbafa1670d88f55246f2bb52117cb48", "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": 27.6666666667, "max_line_length": 73, "alphanum_fraction": 0.5535081502, "num_tokens": 457, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303285397349, "lm_q2_score": 0.7431680086124811, "lm_q1q2_score": 0.5874968500086453}}
{"text": "import Data.Vect as V\nimport Data.Vect.Extra\nimport Data.Nat\nimport Data.List as L\nimport Data.String.Parser\n\nimport System.File\n\ndata Cucumber = H | V\n\nisH : Maybe Cucumber -> Bool\nisH (Just H) = True\nisH _ = False\n\nisV : Maybe Cucumber -> Bool\nisV (Just V) = True\nisV _ = False\n\nGrid : Nat -> Nat -> Type\nGrid x y = Vect (S y) (Vect (S x) (Maybe Cucumber))\n\ncucumberParser : Parser (Maybe Cucumber)\ncucumberParser = char '>' $> Just H <|> char 'v' $> Just V <|> char '.' $> Nothing\n\nparser : Parser (x ** y ** Grid x y)\nparser = do row <- some cucumberParser <* char '\\n'\n let x = length row\n Just v <- pure $ toVect x row\n | Nothing => fail \"not length\"\n Yes ItIsSucc <- pure $ isItSucc x\n | No _ => fail \"Row is zero\"\n cs <- some ((ntimes x cucumberParser) <* char '\\n')\n let y = length cs\n Just cs <- pure $ toVect y cs\n | Nothing => fail \"not column\"\n pure $ (_ ** (_ ** v :: cs))\n\nMove : Nat -> Nat -> Type\nMove x y = ((Fin (S x), Fin (S y)), (Fin (S x), Fin (S y)))\n\naddWrap : {n : Nat} -> Fin (S n) -> Fin (S n)\naddWrap f = case strengthen $ shift 1 f of\n Nothing => 0\n (Just f) => f\n\nhMoves : {x : Nat} -> {y : Nat} -> Grid x y -> List (Move x y)\nhMoves g = filter (\\(_,(x,y)) => isNothing $ index x $ index y g) $ map (\\(x,y,_) => ((x, y), (addWrap x, y))) $ toList $ join $ toList $ (\\(y,xs) => filter (isH . snd . snd) $ toList $ mapWithPos (,y,) $ xs) <$> mapWithPos (,) g\n\nvMoves : {x : Nat} -> {y : Nat} -> Grid x y -> List (Move x y)\nvMoves g = filter (\\(_,(x,y)) => isNothing $ index x $ index y g) $ map (\\(x,y,_) => ((x, y), (x, addWrap y))) $ toList $ join $ toList $ (\\(y,xs) => filter (isV . snd . snd) $ toList $ mapWithPos (,y,) $ xs) <$> mapWithPos (,) g\n\nsteps : {x : Nat} -> {y : Nat} -> Grid x y -> Nat\nsteps g = steps' 1 g\n where\n doMoves : Grid x y -> List (Move x y) -> Grid x y\n doMoves g [] = g\n doMoves g (((x1, y1), (x2, y2)) :: ms) = let c = index x1 $ index y1 g \n g1 = updateAt y1 (replaceAt x1 Nothing) g\n g2 = updateAt y2 (replaceAt x2 c) g1 in\n doMoves g2 ms\n\n steps' : Nat -> Grid x y -> Nat\n steps' n g = case hMoves g of\n [] => case vMoves g of\n [] => n\n ms => steps' (S n) (doMoves g ms)\n ms => let g' = doMoves g ms in\n case vMoves g' of\n [] => steps' (S n) g'\n ms => steps' (S n) (doMoves g' ms)\n\n\npart1 : {n : Nat} -> {m : Nat} -> Grid n m -> IO String\npart1 a = pure $ show $ steps a\n\nmain : IO ()\nmain = do Right input <- readFile \"input.txt\"\n | Left err => printLn err\n Right (MkDPair n (MkDPair m a), _) <- pure $ parse parser input\n | Left err => printLn err\n part1 a >>= putStrLn\n\n", "meta": {"hexsha": "09d5197a9d0694db72f7af22c0bf836641790a52", "size": 3089, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "25/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": "25/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": "25/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": 37.2168674699, "max_line_length": 229, "alphanum_fraction": 0.4703787634, "num_tokens": 933, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267830311354, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.5871223843896978}}
{"text": "\nAdderType : (numargs : Nat) -> Type -> Type\nAdderType Z numType = numType\nAdderType (S k) numType = (next : numType) -> AdderType k numType\n\n\nadder : Num numType => (numargs : Nat) -> numType -> AdderType numargs numType\nadder Z acc = acc\nadder (S k) acc = \\next => adder k (next + acc)\n", "meta": {"hexsha": "8db57ce3640b0d86cb3724fcf96cc691e61e7748", "size": 288, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "ZPF/Slajdy19/PlikiIdrisa/Adder.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/Adder.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/Adder.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": 28.8, "max_line_length": 78, "alphanum_fraction": 0.6631944444, "num_tokens": 98, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8558511396138365, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.5870706227862517}}
{"text": "module Linear.Backprop\n\nimport Backprop\nimport Control.Optics\nimport Linear.V\nimport Linear.Math\nimport Linear.Optics\n\nexport\n{n : _} -> CanBack a => CanBack (V n a) where\n zero = pure zero\n one = pure one\n add [] [] = []\n add (x :: xs) (y :: ys) = add x y :: add xs ys\n\nexport\n(::) : {a, n : _} -> CanBack a => Node s a -> Node s (V n a) -> Node s (V (S n) a)\n(::) = op2 $ \\[x, xs] => (x :: xs, \\(d :: ds) => [d, ds])\n\nexport\n{n : _} -> NodeTraversable (V n) where\n sequence x = map (\\i => x ^. at i) Fin.range\n\nexport\n{n : _} -> NodeDistributive (V n) where\n collect [] = const []\n collect (node :: nodes) = node :: collect nodes\n\nexport\nkonst : {a, n : _} -> Num a => CanBack a => Node i a -> Node i (V n a)\nkonst = op1 $ \\[x] => (pure x, \\d => [sum d])\n\nexport\ndot : {a : _} -> (Num a, CanBack a, Foldable f, Zippable f, NodeFunctor f)\n => Node i (f a) -> Node i (f a) -> Node i a\ndot x y = V.dot (Node.sequence x) (Node.sequence y)\n\ninfixl 7 <.>\nexport\n(<.>) : {a, n : _} -> Num a => CanBack a => Node i (V n a) -> Node i (V n a) -> Node i a\n(<.>) = op2 $ \\[x, y] => (x `dot` y, \\d => let d' = pure d in [d' * y, x * d'])\n\nexport\nouter : {n, m, a : _} -> (Num a, CanBack a) => Node i (T [n] a) -> Node i (T [m] a) -> Node i (T [n, m] a)\nouter = op2 $ \\[x, y] => (x `outer` y, \\d => [d !* y, transpose d !* x])\n\nexport\n(#>) : {m, n, a : _} -> Num a => CanBack a => Node i (T [m, n] a) -> Node i (T [n] a) -> Node i (T [m] a)\n(#>) = op2 $ \\[x, y] => (x !* y, \\d => [d `outer` y, transpose x !* d])\n\n-- export\n-- (<#) : {m, n, a : _} -> Num a => CanBack a => Node i (T [m] a) -> Node i (T [m, n] a) -> Node i (T [n] a)\n\nexport\n(*^) : {a : _} -> CanBack a => Num a => NodeFunctor f => Node i a -> Node i (f a) -> Node i (f a)\n(*^) a = Node.map (a *)\n\nexport\n(^*) : {a : _} -> CanBack a => NodeFunctor f => Num a => Node i (f a) -> Node i a -> Node i (f a)\nx ^* y = y *^ x\n\n-- export\n-- (*!) : {a, f : _} -> (CanBack a, Num a, CanBack (f a), NodeTraversable t, NodeTraversable f, Functor t)\n-- => Node i (t a) -> Node i (t (f a)) -> Node i (f a)\n\ninfixr 7 <>\nexport\n(<>) : {n, p, m, a : _} -> (Num a, CanBack a) => Node i (T [m, n] a) -> Node i (T [n, p] a) -> Node i (T [m, p] a)\n(<>) = op2 $ \\[x, y] => (x !*! y, \\d => [d !*! transpose y, transpose x !*! d])\n\nexport\nasum : {a, n : _} -> Num a => CanBack a => Node i (V n a) -> Node i a\nasum = op1 $ \\[x] => (sum x, \\d => [pure d])\n", "meta": {"hexsha": "2d4f8cb9ed413a3b434fbb24ade25a2751a44f19", "size": 2394, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Linear/Backprop.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/Linear/Backprop.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/Linear/Backprop.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": 32.3513513514, "max_line_length": 114, "alphanum_fraction": 0.484962406, "num_tokens": 994, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8962513648201267, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.5869502947175138}}
{"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\nmy_cong : forall f . (x : a) -> (y : a) -> x = y -> f x = f y\n\nmy_curry : ((a, b) -> c) -> a -> b -> c\n\nmy_uncurry : (a -> b -> c) -> (a, b) -> c\n\nappend : Vect n a -> Vect m a -> Vect (n + m) a\n\nlappend : (1 xs : List a) -> (1 ys : List a) -> List a\n\nzipWith : (a -> b -> c) -> Vect n a -> Vect n b -> Vect n c\n\ndata Env : Vect n Type -> Type where\n ENil : Env []\n ECons : a -> Env xs -> Env (a :: xs)\n\n%name Env es\n\ndata Elem : a -> Vect n a -> Type where\n Here : Elem x (x :: xs)\n There : (p : Elem x xs) -> Elem x (y :: xs)\n\nlookup : Elem ty vs -> Env vs -> ty\n\ndata Tree : (a : Type) -> Type where\n Leaf : a -> Tree a\n Node : a -> Tree a -> Tree a -> Tree a\n\nfoo : Tree Nat\n", "meta": {"hexsha": "0b7ace1b3aa1fb2b424c6cd5256266357d5aeeb0", "size": 821, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/interactive005/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": 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/tests/idris2/interactive005/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": 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/tests/idris2/interactive005/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": 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": 22.8055555556, "max_line_length": 61, "alphanum_fraction": 0.4799025579, "num_tokens": 300, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637361282707, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.5867838811569256}}
{"text": "module chap06_printf\n\n-- intermediate type\ndata Format = Number Format -- %d\n | Str Format -- %s\n | Lit String Format\n | End\n\nPrintfType : Format -> Type\nPrintfType (Number f) = (i : Int) -> PrintfType f\nPrintfType (Str f) = (str : String) -> PrintfType f\nPrintfType (Lit s f) = PrintfType f\nPrintfType End = String\n\n-- helper function\nprintfFmt : (f : Format) -> (acc : String) -> PrintfType f\nprintfFmt (Number f) acc = \\i => printfFmt f (acc ++ show i)\nprintfFmt (Str f) acc = \\str => printfFmt f (acc ++ str)\nprintfFmt (Lit s f) acc = printfFmt f (acc ++ s)\nprintfFmt End acc = acc\n\ntoFormat : (xs : List Char) -> Format\ntoFormat [] = End\ntoFormat ('%' :: 'd' :: chars) = Number (toFormat chars)\ntoFormat ('%' :: 's' :: chars) = Str (toFormat chars)\ntoFormat ('%' :: chars) = Lit \"%\" (toFormat chars)\ntoFormat (c :: chars) = case toFormat chars of\n Lit lit chars' => Lit (strCons c lit) chars'\n fmt => Lit (strCons c \"\") fmt\n\nprintf : (fmt : String) -> PrintfType (toFormat (unpack fmt))\nprintf fmt = printfFmt _ \"\"\n\n-- *chap06_printf> :t printf\n-- printf : (fmt : String) -> PrintfType (toFormat (unpack fmt))\n-- *chap06_printf> printf \"hey, %s\"\n-- \\str => prim__concat \"hey, \" str : String -> String\n-- *chap06_printf> printf \"hey, %s\" \"you\"\n-- \"hey, you\" : String\n", "meta": {"hexsha": "95a1cc92396ca2207a452a4dbf419be9f27b995c", "size": 1405, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "starting/chap06_printf.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/chap06_printf.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/chap06_printf.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": 35.125, "max_line_length": 82, "alphanum_fraction": 0.5786476868, "num_tokens": 401, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.7217432062975979, "lm_q1q2_score": 0.5866814642706188}}
{"text": "module Toolkit.Data.DList.Elem\n\nimport Toolkit.Data.DList\n\nimport public Toolkit.Decidable.Equality.Indexed\n\n%default total\n\n||| Proof that some element is found in a `DList`.\n|||\n||| @iTy The type of the element's index.\n||| @elemTy The type of the list element.\n||| @x An element in the list.\n||| @xs The list itself.\n||| @prf Proof that the element's index is in the list in the same position as the element itself.\npublic export\ndata Elem : (iTy : Type)\n -> (elemTy : iTy -> Type)\n -> forall i, is\n . (x : elemTy i)\n -> (xs : DList iTy elemTy is)\n -> Type\n where\n ||| Proof that the element is at the front of the list.\n H : (Equals ity elemTy x y) -> Elem ity elemTy x (y :: xs)\n\n ||| Proof that the element is found later in the list.\n T : (later : Elem iTy elemTy x xs)\n -> Elem iTy elemTy x (x' ::xs)\n\n\nlistEmpty : Elem type e thing Nil -> Void\nlistEmpty (H x) impossible\nlistEmpty (T later) impossible\n\nnotInLater : (contraE : Equals type e x y -> Void)\n -> (contraR : Elem type e x xs -> Void)\n -> (prf : Elem type e x (y::xs))\n -> Void\nnotInLater contraE contraR (H z) = contraE z\nnotInLater contraE contraR (T later) = contraR later\n\n\nexport\nisElem : {type : Type}\n -> {e : type -> Type}\n -> DecEq type\n => DecEqIdx type e\n => {a : type}\n -> {as : List type}\n -> (thing : e a)\n -> (things : DList type e as)\n -> Dec (Elem type e thing things)\nisElem thing [] = No listEmpty\nisElem thing (elem :: rest) with (Index.decEq thing elem)\n isElem thing (thing :: rest) | (Yes (Same Refl Refl)) = Yes (H (Same Refl Refl))\n isElem thing (elem :: rest) | (No contra) with (isElem thing rest)\n isElem thing (elem :: rest) | (No contra) | (Yes prf) = Yes (T prf)\n isElem thing (elem :: rest) | (No contra) | (No f) = No (notInLater contra f)\n-- [ EOF ]\n", "meta": {"hexsha": "692326670c68df03682cfcca224552fc0ef15184", "size": 1981, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Toolkit/Data/DList/Elem.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/DList/Elem.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/DList/Elem.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.4754098361, "max_line_length": 102, "alphanum_fraction": 0.5739525492, "num_tokens": 585, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430562234877, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.5866083147861295}}
{"text": "module QCont\n\nimport Linear.Types\nimport Linear.Equality\nimport FunExt\n\nimport Syntax.PreorderReasoning\n\n{-\n This file implements quantitative containers, and shows the\n equivalence of initiality and induction for them.\n\n For convenience, we use an Idris data type to implement the\n underlying algebra and pattern matching to implement the mediating\n morphism fold, as this gives us definitional commutation rules for it.\n-}\n\n-- We fix as parameters the shape and position types\nparameters (S : Type, P : S -> Type)\n\n -- Quantative Container || S <| P || interpretation as a functor\n public export\n F : Type -> Type\n F x = Sigma1 S (\\ s => P s -<> x)\n\n infix 10 <$#>\n\n -- F is functorial\n (<$#>) : (f : x -<> y) -> (F x -<> F y)\n f <$#> (a # h) = a # (\\ z => f (h z))\n\n alg : Type -> Type\n alg x = F x -<> x\n\n -- Type for initial algebra; we only use pattern matching to define fold\n data W : Type where\n Con : F W -<> W\n\n -- F-algebra homomorphisms\n infix 10 ==>\n infix 10 #\n data (==>) : alg x -> alg y -> Type where\n (#) : {alpha : alg x} -> {beta : alg y} ->\n (1 fun : x -<> y) ->\n (0 commutes : (arg : F x) -> fun (alpha arg) = beta (fun <$#> arg)) ->\n alpha ==> beta\n\n -- extracting the underlying function of the morphism\n fun : {alpha : alg x} -> {beta : alg y} -> (1 h : alpha ==> beta) -> x -<> y\n fun (f # _) = f\n\n -- extracting the proof that it commutes\n 0 commutes : {alpha : alg x} -> {beta : alg y} -> (h : alpha ==> beta) ->\n (arg : F x) -> fun h (alpha arg) = beta (fun h <$#> arg)\n commutes ( _ # c) = c\n\n -- Equality of morphisms\n infix 10 =@\n 0 (=@) : {alpha : alg x} -> {beta : alg y} -> (f , g : alpha ==> beta) -> Type\n f =@ g = (arg : x) -> fun f arg = fun g arg\n\n 0 eq_H_from_fun : {alpha : alg x} -> {beta : alg y} ->\n (h, g : alpha ==> beta) -> h =@ g -> h = g\n eq_H_from_fun (h # commh) (g # commg) eqp with (funextW eqp)\n eq_H_from_fun (h # commh) (h # commg) eqp | Refl = lcong (\\comm => h # comm) eq_comm\n where\n 0 eq_comm : commh = commg\n eq_comm = funextW (\\x => uip (commh x) (commg x))\n\n -- composition of F-algebra homomorphisms is an F-algebra homomorphism\n infix 10 .&\n (.&) : {alpha : alg x} -> {beta : alg y} -> {gamma : alg z} ->\n (beta ==> gamma) -> (alpha ==> beta) -> alpha ==> gamma\n (h # commh) .& (g # commg) = (\\ 1 x => h (g x)) # comm\n where\n 0 comm : (x : F x) -> h (g (alpha x)) = gamma ((\\1 x => h (g x)) <$#> x)\n comm x@(s # p) = rewrite commg x in commh (g <$#> x)\n\n -- identity homomorphism\n id_H : (alpha : alg x) -> alpha ==> alpha\n id_H alpha = (\\1 x => x) # \\ (s # p) => Refl\n\n -- mediating map out of mu F\n fold : (alpha : alg x) -> Con ==> alpha\n fold alpha = f # \\ (s # h) => Refl\n where\n f : W -<> x\n f (Con (s # h)) = alpha (s # \\ p => f (h p))\n\n -- uniqueness of the mediating map fold\n 0 uniqueness : {alpha : alg x} -> (g : Con ==> alpha) -> g = fold alpha\n uniqueness {alpha} g = eq_H_from_fun g (fold alpha) (uniq_f g)\n where\n uniq_f : {alpha : alg x} -> (g : Con ==> alpha) -> g =@ fold alpha\n uniq_f {alpha} (g # comm) (Con (s # h)) =\n trans (comm (s # h)) (cong (\\ h => alpha (s # h)) (funext pointwise))\n where\n 0 pointwise : (1 x : P s) -> g (h x) = fun (fold alpha) (h x)\n pointwise p = uniq_f (g # comm) (h p)\n\n\n -- fold to muF is identity\n 0 id_H_eq_foldW : id_H Con = fold Con\n id_H_eq_foldW = uniqueness (id_H Con)\n\n -- induction principle from initiality\n parameters (0 Q : W -> Type)\n\n ind_alg : ((1 s : S) -> (0 h : P s -<> W) ->\n ((1 p : P s) -> Q (h p)) -<> Q (Con (s # h))) -<>\n alg (Sigma0 W Q)\n ind_alg m (s # h) = Con (fst <$#> (s # h)) # m s _ (\\1 p => snd (h p))\n\n 0 fst_ind_alg : ((1 s : S) -> (0 h : P s -<> W) ->\n ((1 p : P s) -> Q (h p)) -<> Q (Con (s # h))) -<>\n Con ==> Con\n fst_ind_alg m = (\\1 w => fst (fun (fold (ind_alg m)) w)) # \\(s # h) => Refl\n\n 0 id_H_eq_fia : (1 m : (1 s : S) -> (0 h : P s -<> W) ->\n ((1 p : P s) -> Q (h p)) -<> Q (Con (s # h))) ->\n (id_H Con = fst_ind_alg m)\n id_H_eq_fia m = trans id_H_eq_foldW (sym (uniqueness (fst_ind_alg m)))\n\n 0 id_P_eq_fia : (1 m : (1 s : S) -> (0 h : P s -<> W) ->\n ((1 p : P s) -> Q (h p)) -<> Q (Con (s # h))) ->\n (id_H Con =@ fst_ind_alg m)\n id_P_eq_fia m w = lcongApp (lcong fun (id_H_eq_fia m)) w\n\n public export\n induction : ((1 s : S) -> (0 h : P s -<> W) ->\n ((1 p : P s) -> Q (h p)) -<> Q (Con (s # h))) ->\n (1 w : W) -> Q w\n induction m w = replace {p = Q} (sym (id_P_eq_fia m w)) (snd (fun (fold (ind_alg m)) w))\n\n -- computation rule\n 0 ind_comp : (0 Q : W -> Type) ->\n (m : (1 s : S) -> (0 h : P s -<> W) ->\n ((1 p : P s) -> Q (h p)) -<> Q (Con (s # h))) ->\n (1 s : S) -> (0 h : P s -<> W) ->\n induction Q m (Con (s # h)) = m s h (\\1 p => induction Q m (h p))\n ind_comp q m s h = Calc $\n |~ induction q m (Con (s # h))\n ~~ m s h (\\p => induction q m (h p)) ...(fixQ eq snd_fold)\n where\n 0 fixQ : {g : W -<> W} -> (eq : (\\1 x => x) = g) -> (exp : (0 w : W) -> q (g w)) ->\n replace {p = q} (sym (cong (\\ g => Con (s # (\\z => g (h z)))) eq))\n (m s (\\ z => g (h z)) (\\1 p => exp (h p)))\n = m s h (\\1 p => replace {p = q} (sym (lcongApp eq (h p))) (exp (h p)))\n fixQ Refl v = Refl\n\n 0 fst_fold : W -<> W\n fst_fold w = fst (fun (fold (ind_alg q m)) w)\n\n snd_fold : (0 w : W) -> q (fst_fold w)\n snd_fold w = snd (fun (fold (ind_alg q m)) w)\n\n 0 eq : (\\1 w => w) = (\\1 w => fst_fold w)\n eq = lcong fun (id_H_eq_fia q m)\n\n -- initiality out of induction\n initiality : (alpha : alg x) -> Con ==> alpha\n initiality alpha = (induction (\\ _ => x) (\\ s , _ , ih => alpha (s # ih))) # eq\n where\n 0 eq : (w : F W) ->\n induction (\\ _ => x) (\\ s , _ , ih => alpha (s # ih)) (Con w) =\n alpha (induction (\\ _ => x) (\\ s , _, ih => alpha (s # ih)) <$#> w)\n eq (s # h) = ind_comp (\\ _ => x) (\\s, _, ih => alpha (s # ih)) s h\n\n 0 uniq_morphism_f : (alpha : alg x) -> (f : Con ==> alpha) ->\n fun f = fun (initiality alpha)\n uniq_morphism_f alpha (f # comm) = funext (induction (\\ z => f z = fun (initiality alpha) z) m)\n where\n 0 ihp : (1 s : S) -> (0 h : P s -<> W) ->\n (1 ih : (1 p : P s) -> f (h p) = fun (initiality alpha) (h p)) ->\n (1 p : P s) ->\n f (h p) = induction (\\ _ => x) (\\ s, _, ih => alpha (s # ih)) (h p)\n ihp s h ih p = ih p\n\n 0 m : (1 s : S) -> (0 h : P s -<> W) -> (1 ih : (1 p : P s) -> f (h p) = fun (initiality alpha) (h p)) ->\n f (Con (s # h)) = fun (initiality alpha) (Con (s # h))\n m s h ih = Calc $\n |~ f (Con (s # h))\n ~~ alpha (s # \\1 x => f (h x))\n ...(comm (s # h))\n ~~ alpha (s # \\p => fun (initiality alpha) (h p))\n ...( cong (\\ u => alpha (s # u))\n (funext (ihp s h ih)))\n ~~ fun (initiality alpha) (Con (s # h))\n ...( sym (ind_comp (\\ _ => x) (\\s , _ , h => alpha (s # h)) s h))\n\n 0 uniq_morphism_h : (alpha : alg x) -> (f : Con ==> alpha) -> f = initiality alpha\n uniq_morphism_h alpha f = eq_H_from_fun f (initiality alpha) (lcongApp (uniq_morphism_f alpha f))\n", "meta": {"hexsha": "7d5ae5c4643363e6b25c6cbc9b915209e577cf06", "size": 7511, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "QCont.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": "QCont.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": "QCont.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": 38.9170984456, "max_line_length": 111, "alphanum_fraction": 0.4693116762, "num_tokens": 2655, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933447152497, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.5865713777671875}}
{"text": "> module List.Operations\n\n> import Data.List\n> import Data.List.Quantifiers\n> import Syntax.PreorderReasoning\n\n> import Sigma.Sigma\n> import Fun.Operations\n> -- import NumRefinements\n> import Rel.TotalPreorder\n> import Rel.TotalPreorderOperations\n\n> %default total\n> %access public export\n> %auto_implicits on\n\n\n* |List| is a functor:\n\n> ||| fmap\n> fmap : {A, B : Type} -> (A -> B) -> List A -> List B\n> fmap = map\n\n\n* |List| is a monad:\n\n> ||| ret\n> ret : {A : Type} -> A -> List A\n> ret = pure\n\n> ||| bind\n> bind : {A, B : Type} -> List A -> (A -> List B) -> List B\n> bind = (>>=)\n\n\n* |List| is a container monad:\n\n> |||\n> NonEmpty : {A : Type} -> List A -> Type\n> NonEmpty Nil = Void\n> NonEmpty (a :: as) = Unit\n\n> idThere : {A : Type} ->\n> (a : A) -> (as : List A) ->\n> Sigma A (\\ x => x `Elem` as) -> Sigma A (\\ x => x `Elem` (a :: as))\n> idThere a as (MkSigma x p) = MkSigma x (There p)\n\n> ||| Tagging\n> tagElem : {A : Type} -> (as : List A) -> List (Sigma A (\\ a => a `Elem` as))\n> tagElem Nil = Nil\n> tagElem {A} (x :: xs) = (MkSigma x Here) :: (map (idThere x xs) (tagElem xs))\n\n\n* Show\n\n> implementation Show (Elem a as) where\n> show = show' where\n> show' : {A : Type} -> {a : A} -> {as : List A} -> Elem a as -> String\n> show' Here = \"Here\"\n> show' (There p) = \"There\" ++ show' p\n\n> showlong : Show a => List a -> String\n> showlong xs = \" [\" ++ show' \"\" xs ++ \"]\" where \n> show' acc [] = acc \n> show' acc [x] = acc ++ show x \n> show' acc (x :: xs) = show' (acc ++ show x ++ \",\\n\" ++ \" \") xs\n\n\n* Reduction operators\n\n> |||\n> max : {A : Type} -> {R : A -> A -> Type} -> \n> TotalPreorder R -> (as : List A) -> List.Operations.NonEmpty as -> A\n> max tp Nil p = absurd p\n> max tp (a :: Nil) _ = a\n> max tp (a :: a' :: abs) _ with (max tp (a' :: abs) ())\n> | m with (totalPre tp a m)\n> | (Left _) = m\n> | (Right _) = a\n\n> |||\n> argmaxMax : {A, B : Type} -> {R : B -> B -> Type} -> \n> TotalPreorder R -> (abs : List (A, B)) -> List.Operations.NonEmpty abs -> (A, B)\n> argmaxMax tp Nil p = absurd p\n> argmaxMax tp ((a, b) :: Nil) _ = (a, b)\n> argmaxMax tp ((a, b) :: (a', b') :: abs) _ with (argmaxMax tp ((a', b') :: abs) ())\n> | (argmax, max) with (totalPre tp b max)\n> | (Left _) = (argmax, max)\n> | (Right _) = (a, b)\n\n> |||\n> min : {A : Type} -> {R : A -> A -> Type} -> \n> TotalPreorder R -> (as : List A) -> List.Operations.NonEmpty as -> A\n> {-\n> min tp Nil p = absurd p\n> min tp (a :: Nil) _ = a\n> min tp (a :: a' :: abs) _ with (min tp (a' :: abs) ())\n> | m with (totalPre tp a m)\n> | (Left _) = a\n> | (Right _) = m\n> -}\n> min tp Nil p = absurd p\n> min tp (a :: Nil) _ = a\n> min tp (a :: a' :: abs) _ with (totalPre tp a a')\n> | (Left _) = assert_total (min tp (a :: abs) ())\n> | (Right _) = assert_total (min tp (a' :: abs) ())\n\n\n> |||\n> argminMin : {A, B : Type} -> {R : B -> B -> Type} -> \n> TotalPreorder R -> (abs : List (A, B)) -> List.Operations.NonEmpty abs -> (A, B)\n> argminMin tp Nil p = absurd p\n> argminMin tp ((a, b) :: Nil) _ = (a, b)\n> argminMin tp ((a, b) :: (a', b') :: abs) _ with (argminMin tp ((a', b') :: abs) ())\n> | (argmin, min) with (totalPre tp b min)\n> | (Left _) = (a, b)\n> | (Right _) = (argmin, min)\n\n\n> {-\n\n> |||\n> argmaxMax : {A, B : Type} -> TotalPreorder B -> (abs : List (A, B)) -> List.Operations.NonEmpty abs -> (A, B)\n> argmaxMax tp Nil p = absurd p\n> argmaxMax tp ((a, b) :: Nil) _ = (a, b)\n> argmaxMax tp ((a, b) :: (a', b') :: abs) _ with (argmaxMax tp ((a', b') :: abs) ())\n> | (argmax, max) with (totalPre tp b max)\n> | (Left _) = (argmax, max)\n> | (Right _) = (a, b)\n\n> |||\n> argminMin : {A, B : Type} -> TotalPreorder B -> (abs : List (A, B)) -> List.Operations.NonEmpty abs -> (A, B)\n> argminMin tp Nil p = absurd p\n> argminMin tp ((a, b) :: Nil) _ = (a, b)\n> argminMin tp ((a, b) :: (a', b') :: abs) _ with (argminMin tp ((a', b') :: abs) ())\n> | (argmin, min) with (totalPre tp b min)\n> | (Left _) = (a, b)\n> | (Right _) = (argmin, min)\n\n> -}\n\n> |||\n> sumMapSnd : {A, B : Type} -> (Num B) => List (A, B) -> B\n> sumMapSnd abs = sum (map snd abs)\n\n> |||\n> mapIdRightMult : {A, B : Type} -> (Num B) => (List (A, B), B) -> List (A, B)\n> mapIdRightMult (abs, b) = map (cross id (* b)) abs\n\n> |||\n> mvMult : {A, A', B : Type} -> (Num B) => List (A, B) -> (A -> List (A', B)) -> List (A', B)\n> mvMult abs f = concat (map (mapIdRightMult . (cross f id)) abs)\n> -- mvMult Nil f = Nil\n> -- mvMult ((a, b) :: abs) f = mapIdRightMult (f a, b) ++ mvMult abs f\n\n> |||\n> prods : {B : Type} -> (Num B) => List (B, B) -> List B\n> prods = map (uncurry (*))\n\n> |||\n> sumProds : {B : Type} -> (Num B) => List (B, B) -> B\n> sumProds Nil = 0\n> sumProds ((b,b') :: bbs) = b * b' + sumProds bbs\n\n\n* Filtering\n\n> ||| Filters a list on a decidable property and pairs elements with proofs\n> filterTagSigma : {A : Type} ->\n> {P : A -> Type} ->\n> ((a : A) -> Dec (P a)) ->\n> List A -> \n> List (Sigma A P)\n> filterTagSigma d1P Nil = Nil\n> filterTagSigma d1P (a :: as) with (filterTagSigma d1P as)\n> | tail with (d1P a)\n> | (Yes p) = (MkSigma a p) :: tail\n> | (No _) = tail\n\n> ||| Filters a list on a decidable property and pairs elements with proofs\n> filterTagSubset : {A : Type} ->\n> {P : A -> Type} ->\n> ((a : A) -> Dec (P a)) ->\n> List A -> \n> List (Subset A P)\n> filterTagSubset d1P Nil = Nil\n> filterTagSubset d1P (a :: as) with (filterTagSubset d1P as)\n> | tail with (d1P a)\n> | (Yes p) = (Element a p) :: tail\n> | (No _) = tail\n\n\n* Ad-hoc filtering\n\n> |||\n> discardZeroes : {B : Type} -> (Num B, DecEq B) => List B -> List B\n> discardZeroes Nil = Nil\n> discardZeroes (b :: bs) with (decEq b 0)\n> | (Yes _) = discardZeroes bs\n> | (No _) = b :: discardZeroes bs\n\n> |||\n> discardBySndZero : {A, B : Type} -> (Num B, DecEq B) => List (A, B) -> List (A, B)\n> discardBySndZero Nil = Nil\n> discardBySndZero (ab :: abs) with (decEq (snd ab) 0)\n> | (Yes _) = discardBySndZero abs\n> | (No _) = ab :: discardBySndZero abs\n\n> |||\n> discardBySndZeroEq : {A, B : Type} -> (Num B, Eq B) => List (A, B) -> List (A, B)\n> discardBySndZeroEq Nil = Nil\n> discardBySndZeroEq (ab :: abs) with ((snd ab) == 0)\n> | True = discardBySndZeroEq abs\n> | False = ab :: discardBySndZeroEq abs\n", "meta": {"hexsha": "f6a393acc06e920d0de48aa892c756e484c49754", "size": 6931, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "List/Operations.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": "List/Operations.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": "List/Operations.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.2372093023, "max_line_length": 126, "alphanum_fraction": 0.4680421296, "num_tokens": 2433, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321983146847, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.586480461221242}}
{"text": "import CatenableDeque\nimport FiniteMap\n\nimport BankersDeque\nimport ImplicitCatenableDeque\n\nimport Trie\nimport TrieOfTrees\n\ndata SizedD : (Type -> Type) -> Type -> Type where\n MkSized : (sz : Int) -> (d : dt a) -> SizedD dt a\n\nImplicitCatenableDeque.Sized (SizedD d) where\n size (MkSized sz _) = sz\n\nsubtract : Neg n => n -> n -> n\nsubtract y x = x - y\n\nDeque d => Deque (SizedD d) where\n empty = MkSized 0 empty\n isEmpty (MkSized sz _) = 0 == sz\n cons x (MkSized sz d) = MkSized (1 + sz) (cons x d)\n head (MkSized _ d) = head d\n tail (MkSized sz d) = MkSized (subtract 1 sz) (tail d)\n snoc (MkSized sz d) x = MkSized (sz + 1) (snoc d x)\n last (MkSized _ d) = last d\n init (MkSized sz d) = MkSized (sz - 1) (init d)\n\nCatenableDeque d => CatenableDeque (SizedD d) where\n (MkSized sz1 d1) ++ (MkSized sz2 d2) = MkSized (sz1 + sz2) (d1 ++ d2)\n\ndata BoolMap : Type -> Type -> Type where\n BM : (Maybe a, Maybe a) -> BoolMap Bool a\n\nFiniteMap BoolMap Bool where\n empty = BM (Nothing, Nothing)\n bind False x (BM t) = BM (Just x, snd t)\n bind True x (BM t) = BM (fst t, Just x)\n lookup False (BM t) = fst t\n lookup True (BM t) = snd t\n", "meta": {"hexsha": "9a7abb9afa261f7702e800b27dbb7bdd9514f126", "size": 1143, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Test.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/Test.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/Test.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": 27.8780487805, "max_line_length": 71, "alphanum_fraction": 0.6430446194, "num_tokens": 433, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916240341031, "lm_q2_score": 0.679178699175393, "lm_q1q2_score": 0.5863972000904121}}
{"text": "module Data.Vect.Structural\n\n-- For structural lemmas about (Vect) modules\nimport Control.Algebra\nimport Control.Algebra.VectorSpace -- definition of module\nimport Classes.Verified -- definition of verified algebras other than modules\nimport Control.Algebra.DiamondInstances\nimport Data.Matrix\nimport Data.Matrix.Algebraic -- module instances; from Idris 0.9.20\n\n%default total\n\n\n\n{-\nTheorem (vecHeadtailsEq) for proving equality of (Vect)s by proving equality of their heads and tails. Often used after (headtails).\n\nTheorem (vecIndexwiseEq) for proving equality of (Vect)s by proving indexwise equality of their entries.\n-}\n\n\n\nvecHeadtailsEq : {xs,ys : Vect _ _} -> ( headeq : x = y ) -> ( taileq : xs = ys ) -> x::xs = y::ys\nvecHeadtailsEq {x} {xs} {ys} headeq taileq = trans (vectConsCong x xs ys taileq) $ cong {f=(::ys)} headeq\n-- Also a solid proof:\n-- vecHeadtailsEq {x} {xs} {ys} headeq taileq = trans (cong {f=(::xs)} headeq) $ replace {P=\\l => l::xs = l::ys} headeq $ vectConsCong x xs ys taileq\n\nvecIndexwiseEq : ((i : Fin _) -> index i xs = index i ys) -> xs = ys\nvecIndexwiseEq fn {xs=[]} {ys=[]} = Refl\nvecIndexwiseEq fn {xs=x::xs} {ys=y::ys} = vecHeadtailsEq (fn FZ) $ vecIndexwiseEq {xs=xs} {ys=ys} (\\i => fn $ FS i)\n\n\n\n{-\n* Theorems characterizing (Vect)s of degenerate qualities.\n* Theorems characterizing the index or head of a list created with a certain operation.\n* The theorem (weakenedInd) about comparing an index of a list to an index of its (init).\n* The theorem (extensionalEqToMapEq) extending an extensional equality between functions to one between their (map)s over (Vect)s.\n-}\n\n\n\ntotal\nzeroVecEq : {a : Vect 0 r} -> {b : Vect 0 r} -> a = b\nzeroVecEq {a=[]} {b=[]} = Refl\n\n\n\ntotal\nvecSingletonReplicateEq : ((u : a) -> v=u) -> (xs : Vect n a) -> (xs = replicate n v)\nvecSingletonReplicateEq f [] = Refl\nvecSingletonReplicateEq f (x::xs) {v} = rewrite sym (f x) in cong {f=(v::)} (vecSingletonReplicateEq f xs)\n\n\n\ntotal\nzeroVecVecId : (xs : Vect n (Vect 0 a)) -> (xs = replicate n [])\nzeroVecVecId = vecSingletonReplicateEq (\\b => zeroVecEq {a=[]} {b=b})\n\n\n\ntotal\nheadMapChariz : {xs : Vect (S n) _} -> head $ map f xs = f $ head xs\nheadMapChariz {xs=x::xs} = Refl\n\nmapheadrec : with Data.Vect ( map head (v::vs) = (head v) :: (map head vs) )\nmapheadrec = Refl\n\nheadtails : (v : Vect (S predk) _) -> v = (head v) :: (tail v)\nheadtails (vv::vvs) = Refl\n\n\n\n-- The theorem below this one should not be a necessary weakening, since the functions have equivalent definitions.\n-- indexFZIshead : index FZ = Data.Vect.head\n\ntotal\nindexFZIsheadValued : index FZ xs = head xs\nindexFZIsheadValued {xs=x :: xs} = Refl\n\n\n\nindexReplicateChariz : Data.Vect.index k $ replicate n a = a\nindexReplicateChariz {n=Z} {k} = FinZElim k\nindexReplicateChariz {n=S predn} {k=FZ} = Refl\nindexReplicateChariz {n=S predn} {k=FS prelk} = indexReplicateChariz {k=prelk}\n\nuniformValImpliesReplicate : (a : ty) -> (x : Vect n ty) -> ((i : _) -> index i x = a) -> x = replicate n a\nuniformValImpliesReplicate a [] fn = Refl\nuniformValImpliesReplicate a (x::xs) fn = vecHeadtailsEq (fn FZ) $ uniformValImpliesReplicate a xs (\\i => fn $ FS i)\n\nindexMapChariz : Data.Vect.index k $ map f xs = f $ index k xs\nindexMapChariz {xs=[]} {k} = FinZElim k\n-- indexMapChariz {xs} {f} {k=FZ} = trans indexFZIsheadValued $ trans headMapChariz $ sym $ cong indexFZIsheadValued\nindexMapChariz {xs=x::xs} {f} {k=FZ} = Refl\nindexMapChariz {xs=x::xs} {f} {k=FS k} = indexMapChariz {xs=xs} {f=f} {k=k}\n\nindexUpdateAtChariz : index i $ updateAt i f xs = f $ index i xs\nindexUpdateAtChariz {xs=[]} {i} = FinZElim i\nindexUpdateAtChariz {xs=(x::xs)} {f} {i=FZ} = Refl\nindexUpdateAtChariz {xs=x::xs} {f} {i=FS i} = indexUpdateAtChariz {xs=xs} {f=f} {i=i}\n\nindexUpdateAtChariz2 : Not (i = j) -> index i $ updateAt j f xs = index i xs\nindexUpdateAtChariz2 prneq {i=FZ} {j=FZ} = void $ prneq Refl\nindexUpdateAtChariz2 prneq {i=FS k} {j=FZ} {xs=x::xs} = Refl\nindexUpdateAtChariz2 prneq {i=FZ} {j=FS k} {xs=x::xs} = Refl\nindexUpdateAtChariz2 prneq {i=FS ki} {j=FS kj} {xs=x::xs} = indexUpdateAtChariz2 {xs=xs}\n\t$ prneq . (cong {f=FS})\n\nupdateDeleteAtChariz : deleteAt i $ updateAt i f xs = deleteAt i xs\nupdateDeleteAtChariz {i=FZ} {xs=x::xs} = Refl\nupdateDeleteAtChariz {i=FS k} {xs=x::[]} = FinZElim k\nupdateDeleteAtChariz {i=FS k} {xs=x::x2::xs} = cong {f=(x::)}\n\t$ updateDeleteAtChariz {i=k} {xs=x2::xs}\n\nupdateAtIndIsMapAtInd : index i $ updateAt i f xs = index i $ map f xs\nupdateAtIndIsMapAtInd = trans indexUpdateAtChariz $ sym indexMapChariz\n\ndeleteSuccRowVanishesUnderHead : head $ deleteRow (FS k) xs = head xs\ndeleteSuccRowVanishesUnderHead {xs=x::xs} = Refl\n\nupdateAtSuccRowVanishesUnderHead : head $ updateAt (FS k) f xs = head xs\nupdateAtSuccRowVanishesUnderHead {xs=x::xs} = Refl\n\nzipWithEntryChariz : index i $ Vect.zipWith m x y = m (index i x) (index i y)\nzipWithEntryChariz {x=[]} {y=[]} {i} = FinZElim i\nzipWithEntryChariz {x=(x::xs)} {y=(y::ys)} {i=FZ} = Refl\nzipWithEntryChariz {x=(x::xs)} {y=(y::ys)} {i=FS preli} = zipWithEntryChariz {x=xs} {y=ys} {i=preli}\n\n\n\nplusOneVectIsSuccVect : Vect (n+1) a = Vect (S n) a\nplusOneVectIsSuccVect {a} {n} = sym $ cong {f=\\k => Vect k a} $ trans (cong {f=S} $ sym $ plusZeroRightNeutral n) $ plusSuccRightSucc n Z\n\n{-\nappendedSingletonAsSuccVect : (xs : Vect n a) -> (v : a) -> Vect (S n) a\nappendedSingletonAsSuccVect {a} {n} xs v = rewrite sym $ plusOneVectIsSuccVect {a=a} {n=n} in (xs++[v])\n-}\nappendedSingletonAsSuccVect : (xs : Vect n a) -> (v : a) -> Vect (S n) a\nappendedSingletonAsSuccVect [] v = [v]\nappendedSingletonAsSuccVect (x::xs) v = x::appendedSingletonAsSuccVect xs v\n\n-- With the old implementation of (appendedSingletonAsSuccVect) this seemed impossible to prove.\nconsAppendedSingleton : {xs : Vect n a} -> appendedSingletonAsSuccVect (x::xs) v = x::appendedSingletonAsSuccVect xs v\nconsAppendedSingleton {x} {xs} {v} {a} {n} = Refl\n\n{-\n-- Too many problems with this, rewriting the types to handle Nat addition.\nlastInd : {xs : Vect n a} -> Data.Vect.index Data.Fin.last (rewrite sym $ plusOneVectIsSuccVect {a=a} {n=n} in (xs++[v])) = v\n-}\n\n{-\n-- Stopped typechecking once the implementation of (appendedSingletonAsSuccVect) changed.\nlastInd : {xs : Vect n a} -> index Data.Fin.last $ appendedSingletonAsSuccVect xs v = v\nlastInd {xs=[]} = Refl\nlastInd {xs=x::xs} {v} = rewrite consAppendedSingleton {x=x} {xs=xs} {v=v} in (lastInd {xs=xs} {v=v})\n\n-----\n\n\"ERROR ON INTROS\" BUG, CASE, SOLUTION\n\n---\n\n> lastInd {xs=x::xs} = ?lastInd_rhs_2\n\n> :prove lastInd_rhs_2\nlastInd_rhs_2> intro\n\nType mismatch between\n Vect k a = Vect k a\nand\n Vect (S (S k)) a = Vect (S (plus k 1)) a\n\nwhich I think means the type signature for (lastInd) is being reanalyzed in the presence of (x::xs), as if inlined, in such a way that the sucessor to rewrite is the one inside rather than outside, or something.\n\nThis works fine:\n\n> lastInd {xs=x::xs} {v} = the ( (index Data.Fin.last $ appendedSingletonAsSuccVect (x::xs) v) = v ) ?lastInd_rhs_2\n\nand spells out\n\n> lastInd {xs=x::xs} {v} = the ( (index Data.Fin.last $ appendedSingletonAsSuccVect (x::xs) v) = v ) ( rewrite consAppendedSingleton {x=x} {xs=xs} {v=v} in lastInd {xs=xs} {v=v} )\n\n-}\n\n-- Could this be done with the reversal isomorphism of each Fin?\nlastInd : {xs : Vect n a} -> index Data.Fin.last $ appendedSingletonAsSuccVect xs v = v\nlastInd {xs=[]} = Refl\nlastInd {xs=x::xs} {v} = lastInd {xs=xs} {v=v}\n\n{-\n-- Stopped typechecking once the implementation of (appendedSingletonAsSuccVect) changed.\ntotal\nweakenedInd : {xs : Vect n a} -> index (weaken k) $ appendedSingletonAsSuccVect xs v = index k xs\nweakenedInd {xs=[]} {k} = absurd k\nweakenedInd {xs=x::xs} {k=FZ} {v} = rewrite consAppendedSingleton {x=x} {xs=xs} {v=v} in Refl\nweakenedInd {xs=x::xs} {k=FS j} {v} = rewrite consAppendedSingleton {x=x} {xs=xs} {v=v} in weakenedInd {xs=xs} {k=j} {v}\n-}\n\n{-\nCould this be done with the reversal isomorphism of each Fin and a proof that weaken becomes FS under it?\n-}\ntotal\nweakenedInd : {xs : Vect n a} -> index (weaken k) $ appendedSingletonAsSuccVect xs v = index k xs\nweakenedInd {xs=[]} {k} = absurd k\nweakenedInd {xs=x::xs} {k=FZ} {v} = Refl\nweakenedInd {xs=x::xs} {k=FS j} {v} = weakenedInd {xs=xs} {k=j} {v}\n\n\n\nextensionalEqToMapEq : (exteq : (a : ty) -> (f a = g a)) -> (xs : Vect n ty) -> (map f xs = map g xs)\nextensionalEqToMapEq exteq [] = Refl\nextensionalEqToMapEq exteq (x::xs) = vecHeadtailsEq (exteq x) $ extensionalEqToMapEq exteq xs\n\n\n\n-- Functorial nature of (map).\ncomposeUnderMap : (v : Vect n a)\n\t-> (g : b -> c)\n\t-> (f : a -> b)\n\t-> map g $ map f v = map (g . f) v\ncomposeUnderMap [] g f = Refl\ncomposeUnderMap (v::vs) g f = vecHeadtailsEq Refl $ composeUnderMap vs g f\n\n\n\n{-\nTheorems about the module (Vect n a) over a ring (a):\n* Compatibility between the operations of the ring (a) and of (Vect n a) as a module under (index).\n-}\n\n\n\nindexNeutralIsNeutral1D : Ring a => (k : Fin n) -> index k $ Algebra.neutral {a=Vect n a} = Algebra.neutral\nindexNeutralIsNeutral1D FZ = Refl\nindexNeutralIsNeutral1D (FS k) = indexNeutralIsNeutral1D k\n\n-- For completeness's sake, these should have (index FZ) as (head) forms proved.\n\nindexCompatInverse : VerifiedRingWithUnity a => (xs : Vect n a) -> (i : Fin n) -> index i $ inverse xs = inverse $ index i xs\nindexCompatInverse [] i = FinZElim i\nindexCompatInverse (x::xs) FZ = Refl\nindexCompatInverse (x::xs) (FS preli) = indexCompatInverse xs preli\n\nindexCompatAdd : VerifiedRingWithUnity a => (xs, ys : Vect n a) -> (i : Fin n) -> index i $ xs <+> ys = index i xs <+> index i ys\nindexCompatAdd xs ys i = zipWithEntryChariz {x=xs} {y=ys} {i=i} {m=(<+>)}\n\nindexCompatSub : VerifiedRingWithUnity a\n\t=> {auto ok :\n\t\t((<+>) @{vrwuSemigroupByGrp $ the (VerifiedRingWithUnity a) %instance})\n\t\t= ((<+>) @{vrwuSemigroupByVMon $ the (VerifiedRingWithUnity a) %instance})\n\t\t}\n\t-> (xs, ys : Vect n a)\n\t-> (i : Fin n)\n\t-> index i $ xs <-> ys = index i xs <-> index i ys\nindexCompatSub {ok} xs ys i = rewrite ok in\n\ttrans (indexCompatAdd xs (inverse ys) i)\n\t$ cong {f=((index i xs)<+>)}\n\t$ indexCompatInverse ys i\n\nindexCompatScaling : VerifiedRingWithUnity a\n\t=> {auto ok :\n\t\t((<.>) @{vrwuRingByRWU $ the (VerifiedRingWithUnity a) %instance})\n\t\t= ((<.>) @{vrwuRingByVR $ the (VerifiedRingWithUnity a) %instance})\n\t\t}\n\t-> (r : a) -> (xs : Vect n a) -> (i : Fin n)\n\t-> index i $ r <#> xs = r <.> index i xs\nindexCompatScaling r [] i = FinZElim i\nindexCompatScaling r (x::xs) FZ {ok} = cong {f=\\t => t r x} ok\nindexCompatScaling r (x::xs) (FS preli) = indexCompatScaling r xs preli\n\n\n\n{-\n* The recursive equation for (foldr) over (Vect)s.\n* The recursive equation for sums in (Monoid)s over a (Vect _).\n-}\n\n\n\nfoldrImplRec : (f : t -> acc -> acc) -> (e : acc) -> (go : acc -> acc) -> (x : t) -> (xs : Vect n t) -> (foldrImpl f e go (x::xs) = go $ f x $ foldrImpl f e Basics.id xs)\nfoldrImplRec f e go x [] = Refl\nfoldrImplRec f e go x (xx::xxs) = trans (foldrImplRec f e (go . (f x)) xx xxs) $ cong {f=go . (f x)} $ sym $ foldrImplRec f e id xx xxs\n\nmonoidrec : Monoid a => (v : a) -> (vs : Vect n a) -> sum' (v::vs) = v <+> sum' vs\nmonoidrec = foldrImplRec (<+>) Algebra.neutral id\n", "meta": {"hexsha": "830c0cb2b48bd6be2e88f8f282532c3fbd40430e", "size": 11139, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Data/Vect/Structural.idr", "max_stars_repo_name": "runKleisli/verified-integer-gaussian-elimination", "max_stars_repo_head_hexsha": "cbaed9c2d8d77db25bd13c8c53beea8ac320855c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2016-07-12T15:25:52.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-14T05:43:48.000Z", "max_issues_repo_path": "Data/Vect/Structural.idr", "max_issues_repo_name": "runKleisli/verified-integer-gaussian-elimination", "max_issues_repo_head_hexsha": "cbaed9c2d8d77db25bd13c8c53beea8ac320855c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 16, "max_issues_repo_issues_event_min_datetime": "2016-06-10T02:31:24.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-07T16:16:50.000Z", "max_forks_repo_path": "Data/Vect/Structural.idr", "max_forks_repo_name": "runKleisli/verified-integer-gaussian-elimination", "max_forks_repo_head_hexsha": "cbaed9c2d8d77db25bd13c8c53beea8ac320855c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 38.8118466899, "max_line_length": 211, "alphanum_fraction": 0.6732202173, "num_tokens": 3933, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7826624890918021, "lm_q2_score": 0.7490872075132153, "lm_q1q2_score": 0.5862824583791204}}
{"text": "module Control.Algebra.ZZDivisors\n\nimport Control.Algebra\nimport Classes.Verified\nimport Control.Algebra.VectorSpace -- definition of module\n\nimport Data.Matrix\nimport Data.Matrix.Algebraic -- module instances; from Idris 0.9.20\nimport Data.Matrix.AlgebraicVerified\n\nimport Data.Vect.Structural\nimport Data.Matrix.Structural\n\nimport Data.ZZ\nimport Control.Algebra.NumericInstances\nimport Control.Algebra.ZZVerifiedInstances\nimport Data.Matrix.ZZVerified\n\nimport Data.Matrix.ZZModuleSpan\nimport Data.Matrix.LinearCombinations\n\n%default total\n\n\n\n{-\nTrivial lemmas and plumbing\n-}\n\n\n\nbileibniz : (f : a -> b -> c) -> (x1=x2) -> (y1=y2) -> f x1 y1 = f x2 y2\nbileibniz f {x1} {x2} {y1} {y2} xeq yeq = rewrite (cong {f=f} xeq) in cong {f=f x2} yeq\n\n\n\n{-\nA divisibility relation\n-}\n\n\n\n-- Should be modified to account for (gcd x 0 = 0).\nquotientOverZZ : ZZ -> ZZ -> Type\nquotientOverZZ x y = ( d : ZZ ** d<.>y=x )\n\nquotientOverZZrefl : x `quotientOverZZ` x\nquotientOverZZrefl {x} = ( unity ** ringWithUnityIsUnityR x )\n\nquotientOverZZtrans : x `quotientOverZZ` y -> y `quotientOverZZ` z -> x `quotientOverZZ` z\nquotientOverZZtrans (dx ** prx) (dy ** pry) {x} {y} {z} = ( dx<.>dy ** trans (sym $ ringOpIsAssociative dx dy z) $ trans (cong pry) prx )\n\nquotientOverZZreflFromEq : (a=b) -> a `quotientOverZZ` b\nquotientOverZZreflFromEq {a} {b} eq with (quotientOverZZrefl {x=b})\n\t| (d ** pr) = (d ** trans pr $ sym eq)\n\n\n\n{-\nInteractions between integer divisibility and linear combinations\n-}\n\n\n\n||| Examples:\n||| \n||| > divisorByDistrib (Pos 4) ((Pos 8)::(Pos 0)::[]) (\\x => case x of { FZ => (Pos 2 ** Refl); (FS FZ) => (Pos 0 ** Refl) })\n||| \n||| (Pos 2 ** ?divisorByDistrib_pr) : (d : ZZ ** multZ d (Pos 4) = Pos 8)\n||| \n||| > divisorByDistrib (Pos 4) ((Pos 8)::(Pos 4)::[]) (\\x => case x of { FZ => (Pos 2 ** Refl); (FS FZ) => (Pos 1 ** Refl) })\n||| \n||| (Pos 3 ** ?divisorByDistrib_pr) : (d : ZZ ** multZ d (Pos 4) = Pos 12)\n||| \n||| > divisorByDistrib (Pos 4) ((Pos 8)::(Pos 1)::[]) (\\x => case x of { FZ => (Pos 2 ** Refl); (FS FZ) => (Pos 0 ** Refl) })\n||| \n||| ... Type mismatch between 0 and 1\ndivisorByDistrib : (z : ZZ)\n\t-> (x : Vect n ZZ)\n\t-> ( (k : _) -> index k x `quotientOverZZ` z )\n\t-> (LinearCombinations.monoidsum x) `quotientOverZZ` z\ndivisorByDistrib z [] fn = (0 ** ringNeutralIsMultZeroL z)\n{-\n-- Doesn't like the (fn . FS) passed to divisorByDistrib in the recursive step.\ndivisorByDistrib z (xx::xxs) fn with ( divisorByDistrib z xxs (fn . FS) )\n\t| (dxxs ** prxxs) with (fn FZ)\n\t\t| (dxx ** prxx) = (dxx<+>dxxs ** ?divisorByDistrib_pr)\n\t-- divisorByDistrib_pr {z} {xx} {xxs} {fn} {dxx} {dxxs} =\n\t-- \t(dxx<+>dxxs)<.>z\t={ ringOpIsDistributiveR dxx dxxs z }=\n\t-- \t(dxx<.>z)<+>(dxxs<.>z)\t={ cong {f=((dxx<.>z)<+>)} prxxs }=\n\t-- \t(dxx<.>z)<+>sum xxs\t={ cong {f=(<+>_)} prxx }=\n\t-- \txx<+>sum xxs\t={ rewrite sym $ monoidrec1D {v=xx} {vs=xxs} }=\n\t-- \tsum (x::xxs)\tQED\n-}\ndivisorByDistrib z (xx::xxs) {n=S predn} fn = ( dxx<+>dxxs ** divisorByDistrib' )\n\twhere\n\t\tdxx : ZZ\n\t\tdxx = getWitness $ fn FZ\n\t\tprxx : dxx<.>z = xx\n\t\tprxx = getProof $ fn FZ\n\t\tdxxs : ZZ\n\t\t-- Passing (fn . FS) as an arg during proof reqs implicit arg (n).\n\t\t{-\n\t\tIn REPL: \"No such variable __pi_arg7\"\n\t\tOtherwise:\n\t\t\"Type mismatch between\n\t\t\t(k1 : Fin (S k)) ->\n\t\t\tquotientOverZZ (index k1 (xx :: xxs)) z (Type of fn)\n\t\tand\n\t\t\tFin (S k) ->\n\t\t\t(\\k1 =>\n\t\t\t\tquotientOverZZ (index k1 xxs) z) (__pi_arg7) (Expected type)\n\n\t\tSpecifically:\n\t\t\tType mismatch between\n\t\t\t\tindex v1 (xx :: xxs)\n\t\t\tand\n\t\t\t\tindex (__pi_arg7) xxs\n\t\t\"\n\n\t\t> dxxs = getWitness $ divisorByDistrib z xxs (fn . FS)\n\t\t-}\n\t\tdxxs = getWitness $ divisorByDistrib z xxs (\\i => fn (FS i))\n\t\tprxxs : dxxs<.>z = LinearCombinations.monoidsum xxs\n\t\t-- prxxs = getProof $ divisorByDistrib z xxs (fn . FS)\n\t\tprxxs = getProof $ divisorByDistrib z xxs (\\i => fn (FS i))\n\t\t{-\n\t\tIf you only write the following (note the missing (<.>_) from (_<.>_ = _))\n\n\t\t> divisorByDistrib' : (dxx<+>dxxs) = LinearCombinations.monoidsum (xx::xxs)\n\n\t\tthen you get a type mismatch error that looks like\n\n\t\t\"type mismatch between _ and _, specifically between\n\n\t\t\tfoldrImpl (flip plusZ) (Pos 0) (plusZ xx) xxs\n\n\t\tand\n\n\t\t\tfoldrImpl (flip plusZ) (Pos 0) (plusZ xx) xxs\n\t\t\"\n\n\t\twhich is not at all what's wrong, and is an unhelpful error message.\n\t\t-}\n\t\tdivisorByDistrib' : (dxx<+>dxxs)<.>z = LinearCombinations.monoidsum (xx::xxs)\n\t\tdivisorByDistrib' = trans (ringOpIsDistributiveR dxx dxxs z) $ trans (bileibniz (<+>) prxx prxxs) $ sym $ monoidrec1D {v=xx} {vs=xxs}\n\n\n\n{-\nWe need to modify this formula to make the right-hand-argument of (quotientOverZZ) constant. It should perhaps be saying the (quotientOverZZ)'s right-hand-arg lies in the transpose of xs in a constant position.\n-}\nzipWithHeadsQuotientRelation : {zs : Vect (S predn) ZZ} -> {xs : Matrix (S predn) (S predm) ZZ} -> (k : _ ) -> ( index k $ map head $ zipWith (<#>) zs xs ) `quotientOverZZ` (head $ index k xs)\nzipWithHeadsQuotientRelation {zs=z::zs} {xs=(xx::xxs)::xs} FZ = (z ** Refl)\nzipWithHeadsQuotientRelation {zs=z::zs} {xs=(xx::xxs)::xs} {predn=Z} (FS prelk) = FinZElim prelk\nzipWithHeadsQuotientRelation {zs=z::zs} {xs=x::xs} {predn=S prededn} (FS prelk) = zipWithHeadsQuotientRelation {zs=zs} {xs=xs} {predn=prededn} prelk\n\n-- Should be applied to (fn) as given by the gcd equality.\nzipWithHeadsQuotientRelation2 : {zs : Vect (S predn) ZZ} -> {xs : Matrix (S predn) (S predm) ZZ} -> ( fn : ( i : Fin _ ) -> (head $ Vect.index i xs) `quotientOverZZ` (head $ Vect.head xs) ) -> (k : _ ) -> ( Vect.index k $ map head $ Vect.zipWith (<#>) zs xs ) `quotientOverZZ` (head $ Vect.head xs)\nzipWithHeadsQuotientRelation2 {zs} {xs} fn k = quotientOverZZtrans (zipWithHeadsQuotientRelation {zs=zs} {xs=xs} k) (fn k)\n\nlinearComboQuotientRelation : (x : Vect (S predm) ZZ) -> (xs : Matrix predn (S predm) ZZ) -> (z : Vect (S predn) ZZ)\n\t-> ( fn : ( i : Fin _ ) -> (head $ Vect.index i (x::xs)) `quotientOverZZ` (head x) )\n\t-> ( LinearCombinations.monoidsum $\n\t\t\tmap head $\n\t\t\tzipWith (<#>) z (x::xs) )\n\t\t`quotientOverZZ` (head x)\nlinearComboQuotientRelation x xs z fn = divisorByDistrib _ _ (zipWithHeadsQuotientRelation2 {zs=z} {xs=x::xs} fn)\n\n-- Motivation: succImplWknStep_Qfunclemma\nlinearComboQuotientRelation_corrollary : (x : Vect (S predm) ZZ) -> (xs : Matrix predn (S predm) ZZ) -> (z : Vect (S predn) ZZ)\n\t-> ( fn : ( i : Fin _ ) -> (head $ Vect.index i (x::xs)) `quotientOverZZ` (head x) )\n\t-> ( head $\n\t\t\tLinearCombinations.monoidsum $\n\t\t\tzipWith (<#>) z (x::xs) )\n\t\t`quotientOverZZ` (head x)\nlinearComboQuotientRelation_corrollary x xs z fn = quotientOverZZtrans (quotientOverZZreflFromEq $ headOfSumIsSumOfHeads _) $ linearComboQuotientRelation x xs z fn\n", "meta": {"hexsha": "489f41f6fbee729b8503562bff76ce40561e812d", "size": 6641, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Control/Algebra/ZZDivisors.idr", "max_stars_repo_name": "runKleisli/verified-integer-gaussian-elimination", "max_stars_repo_head_hexsha": "cbaed9c2d8d77db25bd13c8c53beea8ac320855c", "max_stars_repo_licenses": ["CC-BY-4.0"], "max_stars_count": 8, "max_stars_repo_stars_event_min_datetime": "2016-07-12T15:25:52.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-14T05:43:48.000Z", "max_issues_repo_path": "Control/Algebra/ZZDivisors.idr", "max_issues_repo_name": "runKleisli/verified-integer-gaussian-elimination", "max_issues_repo_head_hexsha": "cbaed9c2d8d77db25bd13c8c53beea8ac320855c", "max_issues_repo_licenses": ["CC-BY-4.0"], "max_issues_count": 16, "max_issues_repo_issues_event_min_datetime": "2016-06-10T02:31:24.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-07T16:16:50.000Z", "max_forks_repo_path": "Control/Algebra/ZZDivisors.idr", "max_forks_repo_name": "runKleisli/verified-integer-gaussian-elimination", "max_forks_repo_head_hexsha": "cbaed9c2d8d77db25bd13c8c53beea8ac320855c", "max_forks_repo_licenses": ["CC-BY-4.0"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 37.308988764, "max_line_length": 298, "alphanum_fraction": 0.6482457461, "num_tokens": 2504, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199552262967, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.5857094568590273}}
{"text": "module Data.IxRel\n\n%access public export\n%default total\n\n||| Indexed binary relations\ndata IxRel : (a -> b -> c) -> c -> a -> b -> Type where\n MkIxRel : IxRel p (p a b) a b\n\n||| A binary boolean predicate\nPredicate : (a -> b -> Bool) -> a -> b -> Type\nPredicate p x y = IxRel p True x y\n\n||| Given parameters, constructs the index and relation\nrelate : (p : a -> b -> c) -> (x : a) -> (y : b) -> (q ** IxRel p q x y)\nrelate p x y = (p x y ** MkIxRel)\n\n||| Helper for decide\nprivate\nunique : IxRel p w x y -> IxRel p q x y -> w = q\nunique MkIxRel MkIxRel = Refl\n\n||| Given parameters and an index, decides if a relation exists for that index\ndecide : DecEq c => (p : a -> b -> c) -> (w : c) -> (x : a) -> (y : b) -> Dec (IxRel p w x y)\ndecide p w x y with (relate p x y)\n | (q ** pf) =\n case decEq w q of\n Yes pfe => Yes (rewrite pfe in pf)\n No contra => No (\\r => contra (unique r pf))\n\n||| Decide specialized to predicates\ndecidePredicate : (p : a -> b -> Bool) -> (x : a) -> (y : b) -> Dec (Predicate p x y)\ndecidePredicate p x y = decide p True x y\n", "meta": {"hexsha": "e82d4affc8f59095f778950267e6f13f9bcc4ec3", "size": 1067, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/IxRel.idr", "max_stars_repo_name": "ejconlon/idris-array", "max_stars_repo_head_hexsha": "a8ac35058cd2d3e06b0815bf8db76869bc932415", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2018-01-08T12:09:43.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-14T18:13:26.000Z", "max_issues_repo_path": "src/Data/IxRel.idr", "max_issues_repo_name": "ejconlon/ixarray", "max_issues_repo_head_hexsha": "a8ac35058cd2d3e06b0815bf8db76869bc932415", "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/IxRel.idr", "max_forks_repo_name": "ejconlon/ixarray", "max_forks_repo_head_hexsha": "a8ac35058cd2d3e06b0815bf8db76869bc932415", "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.3823529412, "max_line_length": 93, "alphanum_fraction": 0.5810684161, "num_tokens": 370, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891392358014, "lm_q2_score": 0.712232184238947, "lm_q1q2_score": 0.5855895664954545}}
{"text": "module SumsAndProducts\n\nimport public Category\nimport public Isomorphism\nimport public Universality\n\n%default total\n\nTypeOperator : Category -> Type\nTypeOperator cat = Object cat -> Object cat -> Object cat\n\nIsUnitOf : {cat : Category} -> TypeOperator cat -> Object cat -> Type\nIsUnitOf {cat} op u = (a : Object cat) ->\n (Isomorphic (op u a) a, Isomorphic (op a u) a)\n\nTypeOperatorIsAssociative : {cat : Category} -> (op : TypeOperator cat) -> Type\nTypeOperatorIsAssociative {cat} op = (a, b, c : Object cat) ->\n Isomorphic (op a (op b c)) (op (op a b) c)\n\nIsMonoid : {cat : Category} -> TypeOperator cat -> Object cat -> Type\nIsMonoid op u = (TypeOperatorIsAssociative op, IsUnitOf op u)\n\npublic export\nProjectionsFrom : {cat : Category} -> (source, target, target' : Object cat) ->\n Type\nProjectionsFrom {cat} source target target' =\n (Morphism cat source target, Morphism cat source target')\n\npublic export\nInjectionsTo : {cat : Category} -> (target, source, source' : Object cat) ->\n Type\nInjectionsTo {cat} target source source' =\n (Morphism cat source target, Morphism cat source' target)\n\npublic export\nCandidateProduct : {cat : Category} -> (a, b : Object cat) -> Type\nCandidateProduct {cat} a b = (c : Object cat ** ProjectionsFrom c a b)\n\npublic export\nCandidateCoproduct : {cat : Category} -> (a, b : Object cat) -> Type\nCandidateCoproduct {cat} a b = (c : Object cat ** InjectionsTo c a b)\n\npublic export\nIsProduct : {cat : Category} -> (a, b : Object cat) ->\n CandidateProduct {cat} a b -> Type\nIsProduct {cat} a b c =\n (c' : CandidateProduct a b) ->\n (m : Morphism cat (fst c') (fst c) **\n IsUniqueMorphismWithProperty\n (\\m' =>\n ((fst (snd c)) .* m = (fst (snd c')),\n (snd (snd c)) .* m = (snd (snd c')))) m)\n\npublic export\nIsCoproduct : {cat : Category} -> (a, b : Object cat) ->\n CandidateCoproduct {cat} a b -> Type\nIsCoproduct {cat} a b c =\n (c' : CandidateCoproduct a b) ->\n (m : Morphism cat (fst c) (fst c') **\n IsUniqueMorphismWithProperty\n (\\m' =>\n (m .* (fst (snd c)) = (fst (snd c')),\n m .* (snd (snd c)) = (snd (snd c')))) m)\n\npublic export\nProduct : {cat : Category} -> (a, b : Object cat) -> Type\nProduct a b = DPair (CandidateProduct a b) (IsProduct a b)\n\npublic export\ncandidateProduct : {cat : Category} -> {a, b : Object cat} ->\n Product {cat} a b -> CandidateProduct {cat} a b\ncandidateProduct {cat} prod = fst prod\n\npublic export\nproductObject : {cat : Category} -> {a, b : Object cat} ->\n Product {cat} a b -> Object cat\nproductObject {cat} prod = fst (candidateProduct prod)\n\npublic export\nproductProjections : {cat : Category} -> {a, b : Object cat} ->\n (prod : Product {cat} a b) ->\n ProjectionsFrom {cat} (productObject {cat} {a} {b} prod) a b\nproductProjections {cat} {a} {b} prod = snd (candidateProduct {a} {b} prod)\n\npublic export\nproductProperty : {cat : Category} -> {a, b : Object cat} ->\n (prod : Product {cat} a b) ->\n IsProduct {cat} a b (candidateProduct {cat} {a} {b} prod)\nproductProperty {cat} prod = snd prod\n\npublic export\nCoproduct : {cat : Category} -> (a, b : Object cat) -> Type\nCoproduct a b = DPair (CandidateCoproduct a b) (IsCoproduct a b)\n\npublic export\ncandidateCoproduct : {cat : Category} -> {a, b : Object cat} ->\n Coproduct {cat} a b -> CandidateCoproduct {cat} a b\ncandidateCoproduct {cat} prod = fst prod\n\npublic export\ncoproductObject : {cat : Category} -> {a, b : Object cat} ->\n Coproduct {cat} a b -> Object cat\ncoproductObject {cat} coprod = fst (candidateCoproduct coprod)\n\npublic export\ncoproductProperty : {cat : Category} -> {a, b : Object cat} ->\n (coprod : Coproduct {cat} a b) ->\n IsCoproduct {cat} a b (candidateCoproduct {cat} {a} {b} coprod)\ncoproductProperty {cat} coprod = snd coprod\n\npublic export\ncoproductInjections : {cat : Category} -> {a, b : Object cat} ->\n (coprod : Coproduct {cat} a b) ->\n InjectionsTo {cat} (coproductObject {cat} {a} {b} coprod) a b\ncoproductInjections {cat} {a} {b} coprod =\n snd (candidateCoproduct {a} {b} coprod)\n\npublic export\nHasAllProducts : Category -> Type\nHasAllProducts cat = (a, b : Object cat) -> Product a b\n\npublic export\nHasAllCoproducts : Category -> Type\nHasAllCoproducts cat = (a, b : Object cat) -> Coproduct a b\n\npublic export\nmorphismProduct : {c : Category} ->\n {a, b, b' : Object c} ->\n (prodb : Product {cat=c} b b') ->\n (m : Morphism c a b) -> (m' : Morphism c a b') ->\n Morphism c a (productObject {cat=c} {a=b} {b=b'} prodb)\nmorphismProduct prodb {a} {b} m m' = fst (productProperty prodb (a ** (m, m')))\n\npublic export\nmorphismCoproduct : {c : Category} ->\n {a, a', b : Object c} ->\n (coproda : Coproduct {cat=c} a a') ->\n (m : Morphism c a b) -> (m' : Morphism c a' b) ->\n Morphism c (coproductObject {cat=c} {a=a} {b=a'} coproda) b\nmorphismCoproduct coproda {a} {b} m m' =\n fst (coproductProperty coproda (b ** (m, m')))\n\nparallelMorphismProduct : {c : Category} ->\n {a, a', b, b' : Object c} ->\n (proda : Product {cat=c} a a') ->\n (prodb : Product {cat=c} b b') ->\n (m : Morphism c a b) -> (m' : Morphism c a' b') ->\n Morphism c\n (productObject {cat=c} {a=a} {b=a'} proda)\n (productObject {cat=c} {a=b} {b=b'} prodb)\nparallelMorphismProduct {c} proda prodb m m' =\n let\n projFromA = productProjections proda\n leftProj = m .* (fst projFromA)\n rightProj = m' .* (snd projFromA)\n in\n morphismProduct prodb leftProj rightProj\n\nparallelMorphismCoproduct : {c : Category} ->\n {a, a', b, b' : Object c} ->\n (coproda : Coproduct {cat=c} a a') ->\n (coprodb : Coproduct {cat=c} b b') ->\n (m : Morphism c a b) -> (m' : Morphism c a' b') ->\n Morphism c\n (coproductObject {cat=c} {a=a} {b=a'} coproda)\n (coproductObject {cat=c} {a=b} {b=b'} coprodb)\nparallelMorphismCoproduct {c} coproda coprodb m m' =\n let\n injToB = coproductInjections coprodb\n leftInj = (fst injToB) .* m\n rightInj = (snd injToB) .* m'\n in\n morphismCoproduct coproda leftInj rightInj\n\npublic export\nrecord CartesianClosedCategory where\n CCC_cat : Category\n CCC_initial : Object CCC_cat\n CC_is_initial : IsInitial {cat=CCC_cat} CCC_initial\n CCC_terminal : Object CCC_cat\n CCC_is_terminal : IsTerminal {cat=CCC_cat} CCC_terminal\n CCC_has_all_products : HasAllProducts CCC_cat\n CCC_has_all_sums : HasAllCoproducts CCC_cat\n\npublic export\nCCC_object : (ccc : CartesianClosedCategory) -> Type\nCCC_object ccc = Object (CCC_cat ccc)\n\npublic export\nCCC_morphism : {ccc : CartesianClosedCategory} ->\n CCC_object ccc -> CCC_object ccc -> Type\nCCC_morphism {ccc} a b = Morphism (CCC_cat ccc) a b\n\npublic export\nCCC_id : {ccc : CartesianClosedCategory} -> (a : CCC_object ccc) ->\n CCC_morphism {ccc} a a\nCCC_id {ccc} a = Identity (CCC_cat ccc) a\n\npublic export\nCCC_product : {ccc : CartesianClosedCategory} -> (a, b : CCC_object ccc) ->\n CCC_object ccc\nCCC_product {ccc} a b = fst (fst (CCC_has_all_products ccc a b))\n\npublic export\nCCC_sum : {ccc : CartesianClosedCategory} -> (a, b : CCC_object ccc) ->\n CCC_object ccc\nCCC_sum {ccc} a b = fst (fst (CCC_has_all_sums ccc a b))\n\npublic export\nCCC_morphism_product : {ccc : CartesianClosedCategory} ->\n {a, b, b' : CCC_object ccc} ->\n CCC_morphism {ccc} a b -> CCC_morphism {ccc} a b' ->\n CCC_morphism {ccc} a (CCC_product {ccc} b b')\nCCC_morphism_product {ccc} {b} {b'} m m' =\n morphismProduct (CCC_has_all_products ccc b b') m m'\n\npublic export\nCCC_morphism_sum : {ccc : CartesianClosedCategory} ->\n {a, a', b : CCC_object ccc} ->\n CCC_morphism {ccc} a b -> CCC_morphism {ccc} a' b ->\n CCC_morphism {ccc} (CCC_sum {ccc} a a') b\nCCC_morphism_sum {ccc} {a} {a'} m m' =\n morphismCoproduct (CCC_has_all_sums ccc a a') m m'\n\npublic export\nCCC_first : {ccc : CartesianClosedCategory} -> (a, b : CCC_object ccc) ->\n CCC_morphism {ccc} (CCC_product {ccc} a b) a\nCCC_first a b = fst (productProjections (CCC_has_all_products ccc a b))\n\npublic export\nCCC_second : {ccc : CartesianClosedCategory} -> (a, b : CCC_object ccc) ->\n CCC_morphism {ccc} (CCC_product {ccc} a b) b\nCCC_second a b = snd (productProjections (CCC_has_all_products ccc a b))\n\npublic export\nCCC_left : {ccc : CartesianClosedCategory} -> (a, b : CCC_object ccc) ->\n CCC_morphism {ccc} a (CCC_sum {ccc} a b)\nCCC_left a b = fst (coproductInjections (CCC_has_all_sums ccc a b))\n\npublic export\nCCC_right : {ccc : CartesianClosedCategory} -> (a, b : CCC_object ccc) ->\n CCC_morphism {ccc} b (CCC_sum {ccc} a b)\nCCC_right a b = snd (coproductInjections (CCC_has_all_sums ccc a b))\n\npublic export\nCCC_parallel_morphism_product : {ccc : CartesianClosedCategory} ->\n {a, a', b, b' : CCC_object ccc} ->\n CCC_morphism {ccc} a b -> CCC_morphism {ccc} a' b' ->\n CCC_morphism {ccc} (CCC_product {ccc} a a') (CCC_product {ccc} b b')\nCCC_parallel_morphism_product {ccc} {a} {a'} {b} {b'} m m' =\n parallelMorphismProduct\n (CCC_has_all_products ccc a a') (CCC_has_all_products ccc b b') m m'\n\npublic export\nCCC_parallel_morphism_sum : {ccc : CartesianClosedCategory} ->\n {a, a', b, b' : CCC_object ccc} ->\n CCC_morphism {ccc} a b -> CCC_morphism {ccc} a' b' ->\n CCC_morphism {ccc} (CCC_sum {ccc} a a') (CCC_sum {ccc} b b')\nCCC_parallel_morphism_sum {ccc} {a} {a'} {b} {b'} m m' =\n parallelMorphismCoproduct\n (CCC_has_all_sums ccc a a') (CCC_has_all_sums ccc b b') m m'\n", "meta": {"hexsha": "865534db5c2390fc0774f1a71587b6ebacd91825", "size": 9231, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/SumsAndProducts.idr", "max_stars_repo_name": "rokopt/dao-fp-exercises", "max_stars_repo_head_hexsha": "e5291ca45015c4ee5af49c0d8a256cf7da5b08c1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2021-01-17T17:12:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T03:52:36.000Z", "max_issues_repo_path": "src/SumsAndProducts.idr", "max_issues_repo_name": "rokopt/dao-fp-exercises", "max_issues_repo_head_hexsha": "e5291ca45015c4ee5af49c0d8a256cf7da5b08c1", "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/SumsAndProducts.idr", "max_forks_repo_name": "rokopt/dao-fp-exercises", "max_forks_repo_head_hexsha": "e5291ca45015c4ee5af49c0d8a256cf7da5b08c1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-17T17:12:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-17T17:12:19.000Z", "avg_line_length": 35.2328244275, "max_line_length": 79, "alphanum_fraction": 0.6666666667, "num_tokens": 3032, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577680904463333, "lm_q2_score": 0.6825737408694988, "lm_q1q2_score": 0.5854899742944404}}
{"text": "||| A key-value tree data structure.\n|||\n||| This structure doesn't encode the invariants of the tree and is\n||| *simply* a container. This structure ideally shouldn't be exposed\n||| to the user at all. This structure should be used to build other\n||| data structures. See the modules alongside this for appropriate\n||| interfaces for using the tree.\n|||\n||| @keyTy The type associated with the key.\ndata Tree : (keyTy : Type)\n -> Type\n where\n ||| An empty Tree node.\n Empty : Tree k\n\n ||| A Key Value node in the Tree.\n |||\n ||| @key The key.\n ||| @left The left child of the Node\n ||| @right THe right child of the Node.\n Node : (key : k)\n -> (left : Tree k)\n -> (right : Tree k)\n -> Tree k\n\n%name Tree t, tree\n\n -- ------------------------------------------------------------- [ Definitions ]\ndata Balance : Nat -> Nat -> Type where\n LHeavy : Balance (S n) n\n RHeavy : Balance n (S n)\n Balanced : Balance n n\n\n%name Balance b, bal\n\n||| Indirection ensures that it reduces to at least S n' without\n||| needing to case split on balance.\n|||\n||| Should make proofs easier.\nheight : Balance n m -> Nat\nheight b = S (height' b)\n where\n height' : Balance n m -> Nat\n height' (LHeavy {n}) = S n\n height' (RHeavy {n}) = S n\n height' {n} (Balanced {n}) = n\n\n\n||| Encoding of the AVL tree height invariants.\n|||\n||| @height The height of a Tree.\n||| @tree The tree whose height we are capturing.\ndata AVLInvariant : (height : Nat)\n -> (tree : Tree k)\n -> Type\n where\n ||| A tree of height zero.\n AVLEmpty : AVLInvariant 0 Empty\n ||| A Balanced tree.\n |||\n ||| @left The invariant of the left child.\n ||| @right The invariant of the right child.\n ||| @b The encoding of the nodes' balance.\n AVLNode : (left : AVLInvariant n l)\n -> (right : AVLInvariant m r)\n -> (b : Balance n m)\n -> AVLInvariant (height b) (Node k l r)\n\n%name AVLInvariant inv\n\n||| An AVL Tree.\n|||\n||| Modelled using subset to separate the invariants from the tree\n||| implementation itself.\n|||\n||| @height The height of the Tree.\n||| @keyTy The type associated with the keys.\nAVLTree : (height : Nat)\n -> (keyTy : Type)\n -> Type\nAVLTree n k = Subset (Tree k) (AVLInvariant n)\n\n-- --------------------------------------------------------------- [ Rotations ]\ndata InsertRes : Nat -> (k : Type) -> Type where\n Same : AVLTree n k -> InsertRes n k\n Grew : AVLTree (S n) k -> InsertRes n k\n\n%name InsertRes res, r\n\n||| Process the result of an insertion of a new Key-Value pair into\n||| the Tree, returning the new tree and proof of the new tree's\n||| height.\n|||\n||| `InsertRes` is obtained from the result of running `Tree.insert`.\nrunInsertRes : InsertRes n k -> (n : Nat ** AVLTree n k)\nrunInsertRes (Same t) = (_ ** t)\nrunInsertRes (Grew t) = (_ ** t)\n\n||| Perform a Left rotation.\nrotLeft : k\n -> AVLTree n k\n -> AVLTree (S (S n)) k\n -> InsertRes (S (S n)) k\n-- Impossible because Empty has depth 0 and we know the depth is at least 2 from the type\nrotLeft key l (Element Empty AVLEmpty) impossible\n\nrotLeft key (Element l invl) (Element (Node key' rl rr) (AVLNode invrl invrr Balanced)) =\n Grew $ Element (Node key' (Node key l rl) rr)\n (AVLNode (AVLNode invl invrl RHeavy) invrr LHeavy)\n\nrotLeft key (Element l invl) (Element (Node key' (Node key'' rll rlr) rr) (AVLNode (AVLNode invrll invrlr LHeavy) invrr LHeavy)) =\n Same $ Element (Node key'' (Node key l rll) (Node key' rlr rr)) -- Needs Checking\n (AVLNode (AVLNode invl invrll Balanced) (AVLNode invrlr invrr RHeavy) Balanced)\n\nrotLeft key (Element l invl) (Element (Node key' (Node key'' rll rlr) rr) (AVLNode (AVLNode invrll invrlr RHeavy) invrr LHeavy)) =\n Same $ Element (Node key'' (Node key l rll) (Node key' rlr rr))\n (AVLNode (AVLNode invl invrll LHeavy) (AVLNode invrlr invrr Balanced) Balanced)\n\nrotLeft key (Element l invl) (Element (Node key' (Node key'' rll rlr) rr) (AVLNode (AVLNode invrll invrlr Balanced) invrr LHeavy)) =\n Same $ Element (Node key'' (Node key l rll) (Node key' rlr rr))\n (AVLNode (AVLNode invl invrll Balanced) (AVLNode invrlr invrr Balanced) Balanced) -- Needs Checking\n\nrotLeft key (Element l invl) (Element (Node key' rl rr) (AVLNode invrl invrr RHeavy)) =\n Same $ Element (Node key' (Node key l rl) rr)\n (AVLNode (AVLNode invl invrl Balanced) invrr Balanced)\n\n||| Perform a Right rotation.\nrotRight : k\n -> AVLTree (S (S n)) k\n -> AVLTree n k\n -> InsertRes (S (S n)) k\nrotRight key (Element Empty AVLEmpty) r impossible\n\nrotRight key'' (Element (Node key ll (Node key' lrl lrr))\n (AVLNode invll (AVLNode invlrl invlrr RHeavy) RHeavy)) (Element r invr) =\n Same $ Element (Node key' (Node key ll lrl) (Node key'' lrr r))\n (AVLNode (AVLNode invll invlrl LHeavy) (AVLNode invlrr invr Balanced) Balanced)\nrotRight key'' (Element (Node key ll (Node key' lrl lrr))\n (AVLNode invll (AVLNode invlrl invlrr LHeavy) RHeavy)) (Element r invr) =\n Same $ Element (Node key' (Node key ll lrl) (Node key'' lrr r))\n (AVLNode (AVLNode invll invlrl Balanced) (AVLNode invlrr invr RHeavy) Balanced)\nrotRight key (Element (Node key' ll lr) (AVLNode invll invlr Balanced)) (Element r invr) =\n Grew $ Element (Node key' ll (Node key lr r))\n (AVLNode invll (AVLNode invlr invr LHeavy) RHeavy)\n\nrotRight key (Element (Node key' ll lr) (AVLNode invll invlr LHeavy)) (Element r invr) =\n Same $ Element (Node key' ll (Node key lr r))\n (AVLNode invll (AVLNode invlr invr Balanced) Balanced)\n\nrotRight key (Element (Node key' ll (Node key'' lrl lrr))\n (AVLNode invll (AVLNode invlrl invlrr Balanced) RHeavy)) (Element r invr) =\n Same $ Element (Node key'' (Node key' ll lrl) (Node key lrr r))\n (AVLNode (AVLNode invll invlrl Balanced) (AVLNode invlrr invr Balanced) Balanced)\n\n\n --------------------------------------------------------------- [ Insertion ]\n\n||| Perform an insertion into the tree returning the new tree wrapped\n||| in a description describing the height change.\ndoInsert : (Ord k)\n => k\n -> AVLTree n k\n -> InsertRes n k\ndoInsert newKey (Element Empty AVLEmpty) = Grew (Element (Node newKey Empty Empty)\n (AVLNode AVLEmpty AVLEmpty Balanced))\ndoInsert newKey (Element (Node key l r) (AVLNode invl invr b)) with (compare newKey key)\n doInsert newKey (Element (Node key l r) (AVLNode invl invr b)) | EQ = Same (Element (Node newKey l r) (AVLNode invl invr b))\n\n doInsert newKey (Element (Node key l r) (AVLNode invl invr b)) | LT with (assert_total $ doInsert newKey (Element l invl))\n -- Totality checker not clever enough to see that this is smaller\n doInsert newKey (Element (Node key l r) (AVLNode invl invr b)) | LT | (Same (Element l' invl'))\n = Same $ Element (Node key l' r) (AVLNode invl' invr b)\n doInsert newKey (Element (Node key l r) (AVLNode invl invr LHeavy)) | LT | (Grew (Element l' invl'))\n = rotRight key (Element l' invl') (Element r invr)\n doInsert newKey (Element (Node key l r) (AVLNode invl invr Balanced)) | LT | (Grew (Element l' invl'))\n = Grew $ Element (Node key l' r) (AVLNode invl' invr LHeavy)\n doInsert newKey (Element (Node key l r) (AVLNode invl invr RHeavy)) | LT | (Grew (Element l' invl'))\n = Same $ Element (Node key l' r) (AVLNode invl' invr Balanced)\n\n doInsert newKey (Element (Node key l r) (AVLNode invl invr b)) | GT with (assert_total $ doInsert newKey (Element r invr))\n -- Totality checker not clever enough to see that this is smaller\n doInsert newKey (Element (Node key l r) (AVLNode invl invr b)) | GT | (Same (Element r' invr'))\n = Same $ Element (Node key l r') (AVLNode invl invr' b)\n doInsert newKey (Element (Node key l r) (AVLNode invl invr LHeavy)) | GT | (Grew (Element r' invr'))\n = Same $ Element (Node key l r') (AVLNode invl invr' Balanced)\n doInsert newKey (Element (Node key l r) (AVLNode invl invr Balanced)) | GT | (Grew (Element r' invr'))\n = Grew $ Element (Node key l r') (AVLNode invl invr' RHeavy)\n doInsert newKey (Element (Node key l r) (AVLNode invl invr RHeavy)) | GT | (Grew (Element r' invr'))\n = rotLeft key (Element l invl) (Element r' invr')\n\n||| Insert a key value pair into the tree, returning a the new tree\n||| and possibly its new height.\ninsert : Ord k => k -> AVLTree n k -> (n : Nat ** AVLTree n k)\ninsert k t = runInsertRes (doInsert k t)\n\n||| AVL instance implementation\n|||\n||| @ty The type of the elements in the tree.\ndata AVLImpl : (ty : Type) -> Type\n where\n MkTree : {a : Type } -> AVLTree n a -> AVLImpl a\n\n||| Insert an element into the Tree.\ninsertImpl : (Ord a) => a -> AVLImpl a -> AVLImpl a\ninsertImpl a (MkTree t) = MkTree (snd $ insert a t)\n", "meta": {"hexsha": "420bfd2d2293de32c34bfa7b1a54e45950425e9e", "size": 9635, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris-structures/MyAVL.idr", "max_stars_repo_name": "LucasTornai/pgc-ufabc", "max_stars_repo_head_hexsha": "ae38058644363daa39e6fb44e831d26b27d810ea", "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-structures/MyAVL.idr", "max_issues_repo_name": "LucasTornai/pgc-ufabc", "max_issues_repo_head_hexsha": "ae38058644363daa39e6fb44e831d26b27d810ea", "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-structures/MyAVL.idr", "max_forks_repo_name": "LucasTornai/pgc-ufabc", "max_forks_repo_head_hexsha": "ae38058644363daa39e6fb44e831d26b27d810ea", "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": 46.7718446602, "max_line_length": 141, "alphanum_fraction": 0.5819408407, "num_tokens": 2739, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577680940822761, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.5854899601599639}}
{"text": "||| Position and geometry of Hexagonal grid system\n||| https://www.redblobgames.com/grids/hexagons/\nmodule Bautzen.Pos\n\nimport Data.Nat\nimport Data.Nat.DivMod\nimport Data.Nat.Parity\nimport Data.ZZ\n\nimport public Data.ZZ.Extra\nimport Data.Maybe.Extra\n\n-- Positions & Map\n\n||| A position/hex of the game board encoded as a pair of `Nat`\n||| with bounds\npublic export\ndata Pos : Type where\n Hex : (col : Nat) -> (row : Nat)\n -> { auto cbound : LTE col 22 }\n -> { auto rbound : LTE row 12 }\n -> Pos\n\npublic export\nEq Pos where\n (==) (Hex col row) (Hex col' row') = col == col' && row == row'\n\npublic export\nShow Pos where\n show (Hex c r) = show2Digits c ++ show2Digits r\n where\n show2Digits : Nat -> String\n show2Digits n =\n if n < 9\n then \"0\" ++ show (n + 1)\n else show (n + 1)\n\npublic export\nOrd Pos where\n compare (Hex col row) (Hex col' row') =\n case compare col col' of\n LT => LT\n EQ => compare row row'\n GT => GT\n\n||| Cube coordinates.\n||| Cube coordinates stem from the observation a 2-D hexagonal grid is equivalent\n||| to a diagonal \"slice\" of a 3-D cubic grid. Using cubic coordinates makes it\n||| much easier to compute geometric values.\n||| We only store the `x` (column) and `z` (depth) coordinates instead\n||| of a triple as the `y` dimension can be simply recovered as `-x -z`.\npublic export\ndata Cube : Type where\n MkCube : (x : ZZ) -> (z : ZZ) -> Cube\n\n\n||| Compute the L1 distance between 2 `Cube`s\n||| see [Red Blob Games](https://www.redblobgames.com/grids/hexagons/#distances-cube) page\n||| for details on the (pretty cool) algorithm.\npublic export\ncubeDistance : Cube -> Cube -> Nat\ncubeDistance (MkCube x z) (MkCube x' z') =\n let y = negate x - z\n y' = negate x' - z'\n in max (max (absZ (x - x')) (absZ (y - y'))) (absZ (z - z'))\n\npublic export\nposToCube : Pos -> Cube\nposToCube (Hex col row) =\n let x = cast col\n sign = if odd col then 1 else 0\n z = cast row - divZZNZ (x - sign) 2 {z = PosSIsNotZ }\n in MkCube x z\n\npublic export\ndistance : Pos -> Pos -> Nat\ndistance x y =\n let c1 = posToCube x\n c2 = posToCube y\n in cubeDistance c1 c2\n\npublic export\ndata Mvmt : Type where\n Dec : Mvmt\n Neut : Mvmt\n Inc : Mvmt\n\n\npublic export\nsuccNotLTEZ : Not (LTE (S m) Z)\nsuccNotLTEZ LTEZero impossible\n\npublic export\nfromLTESucc : LTE (S m) (S n) -> LTE m n\nfromLTESucc (LTESucc x) = x\n\npublic export\nlteSuccR : LTE n m -> LTE n (S m)\nlteSuccR LTEZero = LTEZero\nlteSuccR (LTESucc x) = LTESucc (lteSuccR x)\n\npublic export\nlteSuccL : LTE (S n) m -> LTE n m\nlteSuccL (LTESucc x) = lteSuccR x\n\npublic export\nisLte : (m, n : Nat) -> Dec (LTE m n)\nisLte Z n = Yes LTEZero\nisLte (S k) Z = No succNotLTEZ\nisLte (S k) (S j)\n = case isLte k j of\n No contra => No (contra . fromLTESucc)\n Yes prf => Yes (LTESucc prf)\n\n\npublic export\nshiftPos : (x : Nat) -> {bound : Nat} -> (prf : LTE x bound) -> Mvmt -> Maybe (n : Nat ** LTE n bound)\nshiftPos Z prf Dec = Nothing\nshiftPos (S k) prf Dec = Just (k ** lteSuccL prf)\nshiftPos x prf Neut = Just (x ** prf)\nshiftPos x prf Inc {bound} with (isLte (S x) bound)\n shiftPos x prf Inc | (Yes y) = Just (S x ** y)\n shiftPos x prf Inc | (No contra) = Nothing\n\n\npublic export\nmakePos : (pos : Pos) -> (Mvmt, Mvmt) -> Maybe Pos\nmakePos (Hex col row {cbound} {rbound} ) (a, b) = do\n (c' ** p1) <- shiftPos col cbound a\n (r' ** p2) <- shiftPos row rbound b\n pure $ Hex c' r' {cbound = p1} {rbound = p2}\n\n\npublic export\noddShifts : List (Mvmt, Mvmt)\noddShifts = [ (Dec, Neut)\n , (Neut, Dec)\n , (Inc, Neut)\n , (Inc, Inc)\n , (Neut, Inc)\n , (Dec, Inc)\n ]\n\n\npublic export\nevenShifts : List (Mvmt, Mvmt)\nevenShifts = [ (Dec, Dec)\n , (Neut, Dec)\n , (Inc, Dec)\n , (Inc, Neut)\n , (Neut, Inc)\n , (Dec, Neut)\n ]\n\n||| Compute the neighbours of a given position\n||| There are at most 6 neighbours, with side and corner hexes having of\n||| course less.\npublic export\nneighbours : (pos : Pos) -> List Pos\nneighbours (Hex col row) with (col `divMod` (S Z))\n neighbours (Hex col@(Z + (q * (S(S Z)))) row) | (MkDivMod q Z remainderSmall) = catMaybes $ map (makePos (Hex col row)) evenShifts\n neighbours (Hex col@((S Z) + (q * (S(S Z)))) row) | (MkDivMod q (S Z) remainderSmall) = catMaybes $ map (makePos (Hex col row)) oddShifts\n neighbours (Hex ((S (S r)) + (q * (S(S Z)))) _) | (MkDivMod q (S (S r)) LTEZero) impossible\n neighbours (Hex ((S (S r)) + (q * (S(S Z)))) _) | (MkDivMod q (S (S r)) (LTESucc lte)) = absurd $ succNotLTEZ (fromLTESucc lte)\n\nnamespace PosTest\n\n neighbours1_test : (neighbours (Hex 3 3) = [ Hex 2 3, Hex 3 2, Hex 4 3, Hex 4 4, Hex 3 4, Hex 2 4] )\n neighbours1_test = Refl\n\n neighbours_test : (neighbours (Hex 2 2) = [ Hex 1 1, Hex 2 1, Hex 3 1, Hex 3 2, Hex 2 3, Hex 1 2] )\n neighbours_test = Refl\n\n -- distance_to_odd_neighbours_is_1 : map (distance (Hex 3 2)) (neighbours (Hex 3 2)) = [ 1, 1, 1, 1, 1, 1 ]\n -- distance_to_odd_neighbours_is_1 = Refl\n\n -- distance_to_even_neighbours_is_1 : map (distance (Hex 2 2)) (neighbours (Hex 2 2)) = [ 1, 1, 1, 1, 1, 1 ]\n -- distance_to_even_neighbours_is_1 = Refl\n\n -- distance_test : distance (Hex 3 2) (Hex 4 4) = 2\n -- distance_test = Refl\n", "meta": {"hexsha": "561a75e5f88e9d4d5d2f334c954809bc9f891b6a", "size": 5314, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "bautzen1945/idris/Bautzen/Pos.idr", "max_stars_repo_name": "steshaw/hsgames", "max_stars_repo_head_hexsha": "4cf8cd02fcc93d1e030144676e2e1cbf9da2514f", "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": "bautzen1945/idris/Bautzen/Pos.idr", "max_issues_repo_name": "steshaw/hsgames", "max_issues_repo_head_hexsha": "4cf8cd02fcc93d1e030144676e2e1cbf9da2514f", "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": "bautzen1945/idris/Bautzen/Pos.idr", "max_forks_repo_name": "steshaw/hsgames", "max_forks_repo_head_hexsha": "4cf8cd02fcc93d1e030144676e2e1cbf9da2514f", "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": 29.1978021978, "max_line_length": 139, "alphanum_fraction": 0.612721114, "num_tokens": 1877, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333246118695629, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.5854355874055611}}
{"text": "> module Fun.Predicates\n\n\n> %default total\n> %access public export\n> %auto_implicits off\n\n\n> ||| Extensional equality\n> ExtEq : {A, B : Type} -> (f : A -> B) -> (g : A -> B) -> Type\n> ExtEq {A} {B} f g = (a : A) -> f a = g a\n", "meta": {"hexsha": "b50f3b102d3d2f8a09c5f116958f3bedcf0e29e7", "size": 225, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "Fun/Predicates.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": "Fun/Predicates.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": "Fun/Predicates.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": 18.75, "max_line_length": 63, "alphanum_fraction": 0.5377777778, "num_tokens": 87, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8333245953120233, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.585435580963451}}
{"text": "module Solutions.DataTypes\n\n-- If all or almost all functions in a module are provably\n-- total, it is convenient to add the following pragma\n-- at the top of the module. It is then no longer necessary\n-- to annotate each function with the `total` keyword.\n%default total\n\n--------------------------------------------------------------------------------\n-- Enumerations\n--------------------------------------------------------------------------------\n\n-- 1\nand : Bool -> Bool -> Bool\nand True b = b\nand False _ = False\n\nor : Bool -> Bool -> Bool\nor True _ = True\nor False b = b\n\n--2\ndata UnitOfTime = Second | Minute | Hour | Day | Week\n\ntoSeconds : UnitOfTime -> Integer -> Integer\ntoSeconds Second y = y\ntoSeconds Minute y = 60 * y\ntoSeconds Hour y = 60 * 60 * y\ntoSeconds Day y = 24 * 60 * 60 * y\ntoSeconds Week y = 7 * 24 * 60 * 60 * y\n\nfromSeconds : UnitOfTime -> Integer -> Integer\nfromSeconds u s = s `div` toSeconds u 1\n\nconvert : UnitOfTime -> Integer -> UnitOfTime -> Integer\nconvert u1 n u2 = fromSeconds u2 (toSeconds u1 n)\n\n--------------------------------------------------------------------------------\n-- Sum Types\n--------------------------------------------------------------------------------\n\ndata Title = Mr | Mrs | Other String\n\neqTitle : Title -> Title -> Bool\neqTitle Mr Mr = True\neqTitle Mrs Mrs = True\neqTitle (Other x) (Other y) = x == y\neqTitle _ _ = False\n\nisOther : Title -> Bool\nisOther (Other _) = True\nisOther _ = False\n\ndata LoginError = UnknownUser String | InvalidPassword | InvalidKey\n\nshowError : LoginError -> String\nshowError (UnknownUser x) = \"Unknown user: \" ++ x\nshowError InvalidPassword = \"Invalid password\"\nshowError InvalidKey = \"Invalid key\"\n\n--------------------------------------------------------------------------------\n-- Records\n--------------------------------------------------------------------------------\n\n-- 1\nrecord TimeSpan where\n constructor MkTimeSpan\n unit : UnitOfTime\n value : Integer\n\ntimeSpanToSeconds : TimeSpan -> Integer\ntimeSpanToSeconds (MkTimeSpan unit value) = toSeconds unit value\n\n-- 2\neqTimeSpan : TimeSpan -> TimeSpan -> Bool\neqTimeSpan x y = timeSpanToSeconds x == timeSpanToSeconds y\n\n-- alternative equality check using `on` from the Idris Prelude\neqTimeSpan' : TimeSpan -> TimeSpan -> Bool\neqTimeSpan' = (==) `on` timeSpanToSeconds\n\n-- 3\nshowUnit : UnitOfTime -> String\nshowUnit Second = \"s\"\nshowUnit Minute = \"min\"\nshowUnit Hour = \"h\"\nshowUnit Day = \"d\"\nshowUnit Week = \"w\"\n\nprettyTimeSpan : TimeSpan -> String\nprettyTimeSpan (MkTimeSpan Second v) = show v ++ \" s\"\nprettyTimeSpan (MkTimeSpan u v) =\n show v ++ \" \" ++ showUnit u ++ \"(\" ++ show (toSeconds u v) ++ \" s)\"\n\n-- 4\ncompareUnit : UnitOfTime -> UnitOfTime -> Ordering\ncompareUnit = compare `on` (\\x => toSeconds x 1)\n\nminUnit : UnitOfTime -> UnitOfTime -> UnitOfTime\nminUnit x y = case compareUnit x y of\n LT => y\n _ => x\n\naddTimeSpan : TimeSpan -> TimeSpan -> TimeSpan\naddTimeSpan (MkTimeSpan u1 v1) (MkTimeSpan u2 v2) =\n case minUnit u1 u2 of\n u => MkTimeSpan u (convert u1 v1 u + convert u2 v2 u)\n\n--------------------------------------------------------------------------------\n-- Generic Data Types\n--------------------------------------------------------------------------------\n\n-- 1\nmapMaybe : (a -> b) -> Maybe a -> Maybe b\nmapMaybe _ Nothing = Nothing\nmapMaybe f (Just x) = Just (f x)\n\nappMaybe : Maybe (a -> b) -> Maybe a -> Maybe b\nappMaybe (Just f) (Just v) = Just (f v)\nappMaybe _ _ = Nothing\n\nbindMaybe : Maybe a -> (a -> Maybe b) -> Maybe b\nbindMaybe Nothing _ = Nothing\nbindMaybe (Just x) f = f x\n\nfilterMaybe : (a -> Bool) -> Maybe a -> Maybe a\nfilterMaybe f Nothing = Nothing\nfilterMaybe f (Just x) = if (f x) then Just x else Nothing\n\nfirst : Maybe a -> Maybe a -> Maybe a\nfirst Nothing y = y\nfirst (Just x) _ = Just x\n\nlast : Maybe a -> Maybe a -> Maybe a\nlast x y = first y x\n\nfoldMaybe : (acc -> elem -> acc) -> acc -> Maybe elem -> acc\nfoldMaybe f x = maybe x (f x)\n\n-- 2\nmapEither : (a -> b) -> Either e a -> Either e b\nmapEither _ (Left x) = Left x\nmapEither f (Right x) = Right (f x)\n\nappEither : Either e (a -> b) -> Either e a -> Either e b\nappEither (Left x) _ = Left x\nappEither (Right _) (Left x) = Left x\nappEither (Right f) (Right v) = Right (f v)\n\nbindEither : Either e a -> (a -> Either e b) -> Either e b\nbindEither (Left x) _ = Left x\nbindEither (Right x) f = f x\n\nfirstEither : (e -> e -> e) -> Either e a -> Either e a -> Either e a\nfirstEither fun (Left e1) (Left e2) = Left (fun e1 e2)\nfirstEither _ (Left e1) y = y\nfirstEither _ (Right x) _ = Right x\n\n-- instead of implementing this via pattern matching, we use\n-- firstEither and swap the arguments. Since this would mean that\n-- in the case of two `Left`s the errors would be in the wrong\n-- order, we have to swap the arguments of `fun` as well.\n-- Function `flip` from the prelude does this for us.\nlastEither : (e -> e -> e) -> Either e a -> Either e a -> Either e a\nlastEither fun x y = firstEither (flip fun) y x\n\nfromEither : (e -> c) -> (a -> c) -> Either e a -> c\nfromEither f _ (Left x) = f x\nfromEither _ g (Right x) = g x\n\n-- 3\nmapList : (a -> b) -> List a -> List b\nmapList f Nil = Nil\nmapList f (x :: xs) = f x :: mapList f xs\n\nfilterList : (a -> Bool) -> List a -> List a\nfilterList f Nil = Nil\nfilterList f (x :: xs) =\n if f x then x :: filterList f xs else filterList f xs\n\nheadMaybe : List a -> Maybe a\nheadMaybe Nil = Nothing\nheadMaybe (x :: _) = Just x\n\ntailMaybe : List a -> Maybe (List a)\ntailMaybe Nil = Nothing\ntailMaybe (x :: xs) = Just xs\n\nlastMaybe : List a -> Maybe a\nlastMaybe Nil = Nothing\nlastMaybe (x :: Nil) = Just x\nlastMaybe (_ :: xs) = lastMaybe xs\n\ninitMaybe : List a -> Maybe (List a)\ninitMaybe Nil = Nothing\ninitMaybe (x :: Nil) = Just Nil\ninitMaybe (x :: xs) = mapMaybe (x ::) (initMaybe xs)\n\nfoldList : (acc -> elem -> acc) -> acc -> List elem -> acc\nfoldList fun vacc Nil = vacc\nfoldList fun vacc (x :: xs) = foldList fun (fun vacc x) xs\n\n-- 4\nrecord Client where\n constructor MkClient\n name : String\n title : Title\n age : Bits8\n password : Either Bits64 String\n\ndata Credentials = Password String Bits64 | Key String\n\nlogin1 : Client -> Credentials -> Either LoginError Client\nlogin1 c (Password u y) =\n if c.name == u then\n if c.password == Left y then Right c else Left InvalidPassword\n else Left (UnknownUser u)\n\nlogin1 c (Key x) =\n if c.password == Right x then Right c else Left InvalidKey\n\nlogin : List Client -> Credentials -> Either LoginError Client\nlogin Nil (Password u _) = Left (UnknownUser u)\nlogin Nil (Key x) = Left InvalidKey\nlogin (x :: xs) cs = case login1 x cs of\n Right c => Right c\n Left InvalidPassword => Left InvalidPassword\n Left _ => login xs cs\n", "meta": {"hexsha": "64322cb138435e3265303855ff4fa0e798c5edb0", "size": 6961, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Solutions/DataTypes.idr", "max_stars_repo_name": "gahr/idris2-tutorial", "max_stars_repo_head_hexsha": "e180728abb1440cd4e6994967419117052646236", "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/Solutions/DataTypes.idr", "max_issues_repo_name": "gahr/idris2-tutorial", "max_issues_repo_head_hexsha": "e180728abb1440cd4e6994967419117052646236", "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/Solutions/DataTypes.idr", "max_forks_repo_name": "gahr/idris2-tutorial", "max_forks_repo_head_hexsha": "e180728abb1440cd4e6994967419117052646236", "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.3973799127, "max_line_length": 80, "alphanum_fraction": 0.5799454101, "num_tokens": 1924, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696747, "lm_q2_score": 0.740174350576073, "lm_q1q2_score": 0.5851302652320225}}
{"text": "twoPlusTwoNotFive : 2 + 2 = 5 -> Void\ntwoPlusTwoNotFive Refl impossible\n\nvalueNotSucc : (x : Nat) -> x = S x -> Void\nvalueNotSucc _ Refl impossible\n", "meta": {"hexsha": "14431470c9d906d6f0ca092e3815f170312a390e", "size": 148, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris-exercises/Void.idr", "max_stars_repo_name": "0nkery/tt-tutorials", "max_stars_repo_head_hexsha": "a39926989c2f39c718893b99bd857b6d51a172b0", "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-exercises/Void.idr", "max_issues_repo_name": "0nkery/tt-tutorials", "max_issues_repo_head_hexsha": "a39926989c2f39c718893b99bd857b6d51a172b0", "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-exercises/Void.idr", "max_forks_repo_name": "0nkery/tt-tutorials", "max_forks_repo_head_hexsha": "a39926989c2f39c718893b99bd857b6d51a172b0", "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.6666666667, "max_line_length": 43, "alphanum_fraction": 0.7094594595, "num_tokens": 53, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8652240895276223, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.5846878173015219}}
{"text": "module Data.Time.Calendar.OrdinalDate\n\nimport Data.Time.Calendar.Days\nimport public Data.Time.Calendar.Types\n\nimport Text.Format.Decimal\n\n%default total\n\n\n-- --------------------------------------------------------------------------\n\nexport isLeapYear : Year -> Bool\nisLeapYear y = (y `mod` 4 == 0) && ((y `mod` 400 == 0) || (y `mod` 100 /= 0))\n\n\n||| Convert to ISO 8601 Ordinal Date format.\nexport toOrdinalDate : Day -> (Year, DayOfYear)\ntoOrdinalDate (ModifiedJulianDay mjd) =\n let a = mjd + 678575\n quadcent = a `div` 146097\n b = a `mod` 146097\n cent = min (b `div` 36524) 3\n c = b - (cent * 36524)\n quad = c `div` 1461\n d = mod c 1461\n y = min (d `div` 365) 3\n in (quadcent * 400 + cent * 100 + quad * 4 + y + 1,\n fromInteger (d - (y * 365) + 1))\n\nshowOrdinalDate : Day -> String\nshowOrdinalDate x with (toOrdinalDate x)\n showOrdinalDate x | (y, dy) = format' (zeroPad 4) y ++ format' (zeroPad 2) dy\n\n||| Convert from ISO 8601 Ordinal Date format.\n||| Invalid day numbers will be clipped to the correct range (1 to 365 or 366).\nexport fromOrdinalDate : Year -> DayOfYear -> Day\nfromOrdinalDate year day =\n let y = year - 1\n yl = if isLeapYear year then 366 else 365\n d' = cast $ if day < 1 then 1 else if day > yl then yl else day\n in ModifiedJulianDay $ d' + (365 * y) + (y `div` 4) - (y `div` 100) + (y `div` 400) - 678576\n\n\n||| Convert from ISO 8601 Ordinal Date format.\n||| Invalid day numbers return 'Nothing'\nexport fromOrdinalDateValid : Year -> DayOfYear -> Maybe Day\nfromOrdinalDateValid year day =\n let y = year - 1\n yl = if isLeapYear year then 366 else 365\n in if day < 0 || day > yl then Nothing\n else Just $ ModifiedJulianDay $ cast day + (365 * y) + (y `div` 4) - (y `div` 100) + (y `div` 400) - 678576\n\n-- ||| Show in ISO 8601 Ordinal Date format (yyyy-ddd)\n-- showOrdinalDate :: Day -> String\n-- showOrdinalDate date = (show4 y) ++ \"-\" ++ (show3 d)\n-- where\n-- (y, d) = toOrdinalDate date\n\n||| Get the number of the Monday-starting week in the year and the day of the week.\n||| The first Monday is the first day of week 1, any earlier days in the year are week 0 (as @%W@ in 'Data.Time.Format.formatTime').\n||| Monday is 1, Sunday is 7 (as @%u@ in 'Data.Time.Format.formatTime').\nexport mondayStartWeek : Day -> (WeekOfYear, Int)\nmondayStartWeek date =\n let yd = snd $ toOrdinalDate date\n d = date.modifiedJulianDay + 2\n k = d - cast yd\n in (fromInteger ((d `mod` 7) - (k `div` 7)), fromInteger (d `mod` 7) + 1)\n\n\n||| Get the number of the Sunday-starting week in the year and the day of the week.\n||| The first Sunday is the first day of week 1, any earlier days in the year are week 0 (as @%U@ in 'Data.Time.Format.formatTime').\n||| Sunday is 0, Saturday is 6 (as @%w@ in 'Data.Time.Format.formatTime').\nexport sundayStartWeek : Day -> (WeekOfYear, Int)\nsundayStartWeek date =\n let yd = snd $ toOrdinalDate date\n d = date.modifiedJulianDay + 3\n k = d - cast yd\n in (fromInteger ((d `div` 7) - (k `div` 7)), fromInteger (mod d 7))\n\n\n||| The inverse of 'mondayStartWeek'. Get a 'Day' given the year,\n||| the number of the Monday-starting week, and the day of the week.\n||| The first Monday is the first day of week 1, any earlier days in the year\n||| are week 0 (as @%W@ in 'Data.Time.Format.formatTime').\nexport\nfromMondayStartWeek : Year -- ^ Year.\n -> WeekOfYear -- ^ Monday-starting week number (as @%W@ in 'Data.Time.Format.formatTime').\n -> Int -- ^ Day of week.\n -- Monday is 1, Sunday is 7 (as @%u@ in 'Data.Time.Format.formatTime').\n -> Day\nfromMondayStartWeek year w d =\n let firstDay = fromOrdinalDate year 1 -- first day of the year\n zbFirstMonday = (5 - firstDay.modifiedJulianDay) `mod` 7 -- 0-based year day of first monday of the year\n zbWeek = w - 1 -- 0-based week of year\n zbDay = d - 1 -- 0-based day of week\n zbYearDay = zbFirstMonday + 7 * cast zbWeek + cast zbDay -- 0-based day in year\n in addDays zbYearDay firstDay\n\n\nexport\nfromMondayStartWeekValid : Year -- ^ Year.\n -> WeekOfYear -- ^ Monday-starting week number (as @%W@ in 'Data.Time.Format.formatTime').\n -> Int -- ^ Day of week.\n -- Monday is 1, Sunday is 7 (as @%u@ in 'Data.Time.Format.formatTime').\n -> Maybe Day\nfromMondayStartWeekValid year w d =\n if d < 1 || d > 7 then Nothing\n else\n let firstDay = fromOrdinalDate year 1 -- first day of the year\n zbFirstMonday = (5 - firstDay.modifiedJulianDay) `mod` 7 -- 0-based week of year\n zbWeek = w - 1 -- 0-based week number\n zbDay = d - 1 -- 0-based day of week\n zbYearDay = zbFirstMonday + 7 * cast zbWeek + cast zbDay -- 0-based day in year\n in if zbYearDay < 0 || zbYearDay > (if isLeapYear year then 365 else 364)\n then Nothing\n else Just $ addDays zbYearDay firstDay\n\n\n\n||| The inverse of 'sundayStartWeek'. Get a 'Day' given the year and\n||| the number of the day of a Sunday-starting week.\n||| The first Sunday is the first day of week 1, any earlier days in the\n||| year are week 0 (as @%U@ in 'Data.Time.Format.formatTime').\nexport\nfromSundayStartWeek : Year -- ^ Year.\n -> WeekOfYear -- ^ Sunday-starting week number (as @%U@ in 'Data.Time.Format.formatTime').\n -> Int -- ^ Day of week\n -- Sunday is 0, Saturday is 6 (as @%w@ in 'Data.Time.Format.formatTime').\n -> Day\nfromSundayStartWeek year w d =\n let firstDay = fromOrdinalDate year 1 -- first day of the year\n zbFirstSunday = (4 - firstDay.modifiedJulianDay) `mod` 7 -- 0-based year day of first monday of the year\n zbWeek = w - 1 -- 0-based week of year\n zbDay = d -- 0-based day of week\n zbYearDay = zbFirstSunday + 7 * cast zbWeek + cast zbDay -- 0-based day in year\n in addDays zbYearDay firstDay\n\n\nexport\nfromSundayStartWeekValid : Year -- ^ Year.\n -> WeekOfYear -- ^ Sunday-starting week number (as @%U@ in 'Data.Time.Format.formatTime').\n -> Int -- ^ Day of week.\n -- Sunday is 0, Saturday is 6 (as @%w@ in 'Data.Time.Format.formatTime').\n -> Maybe Day\nfromSundayStartWeekValid year w d =\n if d < 0 || d > 6 then Nothing\n else\n let firstDay = fromOrdinalDate year 1 -- first day of the year\n zbFirstSunday = (4 - firstDay.modifiedJulianDay) `mod` 7 -- 0-based week of year\n zbWeek = w - 1 -- 0-based week number\n zbYearDay = zbFirstSunday + 7 * cast zbWeek + cast d -- 0-based day in year\n in if zbYearDay < 0 || zbYearDay > (if isLeapYear year then 365 else 364)\n then Nothing\n else Just $ addDays zbYearDay firstDay\n\n\n-- --------------------------------------------------------------------------\n-- vim: tw=80 sw=2 expandtab :", "meta": {"hexsha": "3c0f9c193ddac4404d203122077f7b538f85d19f", "size": 7024, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "time-calendar-clock/src/Data/Time/Calendar/OrdinalDate.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/Calendar/OrdinalDate.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/Calendar/OrdinalDate.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": 44.1761006289, "max_line_length": 132, "alphanum_fraction": 0.5989464692, "num_tokens": 2054, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677737461006, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.5845089384718164}}
{"text": "module With\n\nf : (n : Nat) -> (m : Nat ** n : Nat ** m = n + n)\nf n with (n + n) proof eq\n f n | Z = (Z ** n ** sym eq)\n f n | (S m) = (S m ** n ** sym eq)\n\ng : List a -> Nat\ng [] = Z\ng (a :: as) with (as ++ as)\n g (b :: bs) | asas = Z\n\nnested : Nat -> Nat\nnested m with (m)\n nested m | Z with (m + m)\n nested m | Z | 0 = 1\n nested m | Z | S k with (k + k)\n nested m | Z | S k | Z = 2\n nested m | Z | S k | S l with (l + l)\n nested m | Z | S k | S l | Z = 3\n nested m | Z | S k | S l | S p = 4\n nested m | S k = 5\n\ndata ANat : Nat -> Type where\n MkANat : (n : Nat) -> ANat n\n\nsomeNats : Nat -> Nat\nsomeNats n with (MkANat n)\n someNats n | m@(MkANat n) with (MkANat n)\n someNats n | p@(MkANat n) | MkANat n = Z\n", "meta": {"hexsha": "07c35866039007a468782caa5d72d1bf7fd91072", "size": 754, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "tests/ideMode/ideMode005/With.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/ideMode/ideMode005/With.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/ideMode/ideMode005/With.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": 24.3225806452, "max_line_length": 50, "alphanum_fraction": 0.4641909814, "num_tokens": 320, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8688267626522813, "lm_q2_score": 0.6723317123102956, "lm_q1q2_score": 0.5841397850350191}}
{"text": "namespace Q1\n\n data DoorState = DoorOpen | DoorClosed\n\n data DoorCmd : Type -> DoorState -> DoorState -> Type where\n Open : DoorCmd () DoorClosed DoorOpen\n Close : DoorCmd () DoorOpen DoorClosed\n RingBell : DoorCmd () state state\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 doorProg : DoorCmd () DoorClosed DoorClosed\n doorProg = do RingBell\n Open\n RingBell\n Close\n\nnamespace Q2\n\n data GuessCmd : Type -> Nat -> Nat -> Type where\n Try : Integer -> GuessCmd Ordering (S guesses) guesses\n\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 {-\n no_guesses : GuessCmd () 0 0\n no_guesses = do Try 10\n Pure ()\n -}\n\nnamespace Q3\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\n Condense : MatterCmd () Gas Liquid\n Freeze : MatterCmd () Liquid Solid\n\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{-\noverMelt : MatterCmd () Solid Gas\noverMelt = do Melt\n Melt\n -}\n", "meta": {"hexsha": "60fb5e5548603e97f1e01eba38d4682cd6854e03", "size": 1820, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "TypeDrivenDevelopment/Chapter13/Exercises/ex_13_1.idr", "max_stars_repo_name": "lambdaxymox/type-driven-development-with-idris", "max_stars_repo_head_hexsha": "e5e55715cd7418f3e6fab8e5658d7518da3fdce7", "max_stars_repo_licenses": ["Apache-2.0", "MIT"], "max_stars_count": 161, "max_stars_repo_stars_event_min_datetime": "2017-02-27T02:28:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-18T22:17:47.000Z", "max_issues_repo_path": "Chapter13/Exercises/ex_13_1.idr", "max_issues_repo_name": "gdevanla/TypeDD-Samples", "max_issues_repo_head_hexsha": "a5c08a13e6a6ec804171526aca10aae946588323", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2017-03-26T23:27:19.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T07:32:25.000Z", "max_forks_repo_path": "Chapter13/Exercises/ex_13_1.idr", "max_forks_repo_name": "gdevanla/TypeDD-Samples", "max_forks_repo_head_hexsha": "a5c08a13e6a6ec804171526aca10aae946588323", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 41, "max_forks_repo_forks_event_min_datetime": "2017-03-19T11:01:54.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-10T05:30:22.000Z", "avg_line_length": 25.2777777778, "max_line_length": 61, "alphanum_fraction": 0.5456043956, "num_tokens": 471, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375735, "lm_q2_score": 0.7185943925708562, "lm_q1q2_score": 0.5841218965021923}}
{"text": "\nmodule Equivalence\n\n-- Proof that small-step and big-step semantics for\n-- the simply-typed lambda calculus are equivalent.\n\n\nimport BigStep\nimport Step\nimport Subst\nimport Term\n\n\n%default total\n%access export\n\n\n--------------------------\n-- Begin: STEP => BIG-STEP\n\nstepToBigStep : Step e1 e2 -> BigStep e2 e3 ->\n BigStep e1 e3\n-- case split in the following order: (Step e1 e2), (BigStep e2 e3)\nstepToBigStep (StRec x) (BStValue _) impossible\n--\nstepToBigStep (StRec x) (BStRecZero z w) = let ih = stepToBigStep x z\n in BStRecZero ih w\n--\nstepToBigStep (StRec x) (BStRecSucc y z) = let ih = stepToBigStep x y\n in BStRecSucc ih z\n--\nstepToBigStep StRecZero x = BStRecZero (BStValue VZero) x\n-- \nstepToBigStep (StRecSucc x) y = BStRecSucc (BStValue x) y\n\nstepToBigStep (StApp1 x) (BStValue _) impossible\n--\nstepToBigStep (StApp1 x) (BStApp w s1 t1) = let ih = stepToBigStep x w\n in BStApp ih s1 t1\n--\nstepToBigStep (StApp2 x z) (BStValue v) impossible\n--\nstepToBigStep (StApp2 x z) (BStApp s1 t1 u) = let ih = stepToBigStep z t1\n in BStApp s1 ih u\n--\nstepToBigStep (StBeta x) y = BStApp (BStValue VAbs) (BStValue x) y\n--\nstepToBigStep (StSucc x) (BStValue v) = case v of\n VAbs impossible\n VZero impossible\n VSucc v' => BStSucc $ stepToBigStep x (BStValue v')\n--\nstepToBigStep (StSucc x) (BStSucc y) = BStSucc $ stepToBigStep x y\n--\nstepToBigStep (StPred x) (BStValue _) impossible\n--\nstepToBigStep (StPred x) (BStPredZero z) = BStPredZero $ stepToBigStep x z\n--\nstepToBigStep (StPred x) (BStPredSucc y) = let ih = stepToBigStep x y \n in BStPredSucc ih\n--\nstepToBigStep StPredZero (BStValue _) = BStPredZero (BStValue VZero)\n--\nstepToBigStep (StPredSucc x) y = BStPredSucc (BStSucc y)\n--\nstepToBigStep (StIfz x) (BStValue _) impossible\n--\nstepToBigStep (StIfz x) (BStIfzZero z w) = let ih = stepToBigStep x z\n in BStIfzZero ih w\n--\nstepToBigStep (StIfz x) (BStIfzSucc w s) = let ih = stepToBigStep x w\n in BStIfzSucc ih s\n--\nstepToBigStep StIfzZero y = BStIfzZero (BStValue VZero) y\n--\nstepToBigStep (StIfzSucc x) y = BStIfzSucc (BStValue (VSucc x)) y\n\n-- End: STEP => BIG-STEP\n------------------------\n\n\n\n-------------------------------\n-- Begin: TRANSSTEP => BIG-STEP\n\ntransStepToBigStep : (TransStep e1 e2) -> (v : Value e2) ->\n BigStep e1 e2\ntransStepToBigStep (TStRefl _) v = BStValue v\ntransStepToBigStep (TStTrans x y) v = let ih = transStepToBigStep y v\n in stepToBigStep x ih\n\n-- End: TRANSSTEP => BIG-STEP\n-----------------------------\n\n\n\n-------------------------------\n-- Begin: BIG-STEP => TRANSSTEP\n\n-- Congruence lemma for '(TApp _ e)':\ncongApp1 : TransStep e1 e2 -> TransStep (TApp e1 e) (TApp e2 e)\ncongApp1 (TStRefl e1) = TStRefl (TApp e1 _)\ncongApp1 (TStTrans x y) = TStTrans (StApp1 x) (congApp1 y)\n\n\n-- Congruence lemma for '(TApp e _)':\ncongApp2 : {v : Value e} -> \n TransStep e1 e2 -> TransStep (TApp e e1) (TApp e e2)\ncongApp2 (TStRefl e1) = TStRefl (TApp _ e1)\ncongApp2 {v = v} (TStTrans x y) = TStTrans (StApp2 v x) (congApp2 {v = v} y)\n\n\n-- Congruence lemma for '(Succ _)':\ncongSucc : TransStep e1 e2 -> TransStep (TSucc e1) (TSucc e2)\ncongSucc (TStRefl e1) = TStRefl (TSucc e1)\ncongSucc (TStTrans x y) = TStTrans (StSucc x) (congSucc y)\n\n\n-- Congruence lemma for '(Pred _)':\ncongPred : TransStep e1 e2 -> TransStep (TPred e1) (TPred e2)\ncongPred (TStRefl e1) = TStRefl (TPred e1)\ncongPred (TStTrans x y) = TStTrans (StPred x) (congPred y)\n\n\n-- Congruence lemma for '(Ifz _ ez es)':\ncongIfz : TransStep e1 e2 -> TransStep (TIfz e1 ez es) (TIfz e2 ez es)\ncongIfz (TStRefl e1) = TStRefl (TIfz e1 _ _)\ncongIfz (TStTrans x y) = TStTrans (StIfz x) (congIfz y)\n\n\n-- Congruence lemma for '(TRec _ e0 e1)':\ncongRec : TransStep e e' -> TransStep (TRec e e0 e1) (TRec e' e0 e1)\ncongRec (TStRefl e) = TStRefl (TRec e _ _)\ncongRec (TStTrans x y) = TStTrans (StRec x) (congRec y)\n\n\nbigStepToTransStep : BigStep e1 e2 -> (TransStep e1 e2, Value e2)\n--\nbigStepToTransStep (BStRecZero y z) = \n let (tst1, v1) = bigStepToTransStep y\n (tst2, v2) = bigStepToTransStep z\n tst = (congRec tst1) .+. StRecZero .++. tst2\n in (tst, v2)\n-- \nbigStepToTransStep (BStRecSucc x y) = \n let (tst1, v1) = bigStepToTransStep x\n (tst2, v2) = bigStepToTransStep y\n tst = (congRec tst1) .+. (StRecSucc v1) .++. tst2\n in (tst, v2)\n--\nbigStepToTransStep (BStValue v) = (TStRefl _, v)\n--\nbigStepToTransStep (BStApp z w t1) = \n let (tst1, v1) = bigStepToTransStep z\n (tst2, v2) = bigStepToTransStep w\n (tst3, v3) = bigStepToTransStep t1\n tst = (congApp1 tst1) .++. (congApp2 {v = VAbs} tst2) .+. (StBeta v2) .++. tst3\n in (tst, v3)\n--\nbigStepToTransStep (BStSucc x) = \n let (tst1, v1) = bigStepToTransStep x\n in (congSucc tst1, VSucc v1)\n--\nbigStepToTransStep (BStPredZero y) = \n let (tst1, v1) = bigStepToTransStep y\n tst = congPred tst1 .+. StPredZero\n in (tst, VZero)\n--\nbigStepToTransStep (BStPredSucc x) = \n let (tst1, VSucc v1) = bigStepToTransStep x\n tst = (congPred tst1) .+. (StPredSucc v1)\n in (tst, v1)\n\nbigStepToTransStep (BStIfzZero z w) = \n let (tst1, v1) = bigStepToTransStep z\n (tst2, v2) = bigStepToTransStep w\n tst = (congIfz tst1) .+. StIfzZero .++. tst2\n in (tst, v2)\n \nbigStepToTransStep (BStIfzSucc w s) = \n let (tst1, VSucc v1) = bigStepToTransStep w\n (tst2, v2) = bigStepToTransStep s\n tst = (congIfz tst1) .+. (StIfzSucc v1) .++. tst2\n in (tst, v2)\n\n-- End: BIG-STEP => TRANSSTEP\n-----------------------------\n\n\n\n", "meta": {"hexsha": "cfe2188946388d8633a7d5e0e16d2c025b0ec7da", "size": 5856, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "total/src/Equivalence.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": "total/src/Equivalence.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": "total/src/Equivalence.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.6596858639, "max_line_length": 85, "alphanum_fraction": 0.6094603825, "num_tokens": 2184, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117855317474, "lm_q2_score": 0.7057850154599562, "lm_q1q2_score": 0.5834807903324524}}
{"text": "\nmodule PnP\n\n-- Progress and Preservation\n\n\nimport Step\nimport Subst\nimport SubstLemmas\nimport Term\nimport Typing\n\n\n%default total\n%access export\n\n\n\n------------------\n-- Begin: PROGRESS\n\n-- Progress: a closed, well-typed term is either a value\n-- or it can take a step in the reduction relation.\n\nprogress : (e : Term) -> \n Typing [] e t ->\n Either (Value e) (e' : Term ** (Step e e'))\n--\nprogress (TVar Z) (TyVar Refl) impossible\nprogress (TVar (S _)) (TyVar Refl) impossible\n--\nprogress (TAbs e) (TyAbs s ty) = Left VAbs\n--\nprogress (TApp e1 e2) (TyApp ty1 ty2) = \n case progress e1 ty1 of\n (Left v1) => case canonicalFun _ ty1 v1 of\n (e1 ** Refl) => case progress e2 ty2 of\n (Left v2) => let st' = StBeta v2\n in Right (_ ** st')\n (Right (_ ** st2)) => let st' = StApp2 v1 st2\n in Right (_ ** st')\n (Right (_ ** st1)) => let st' = StApp1 st1\n in Right (_ ** st')\n-- \nprogress (TRec e1 e2 e3) (TyRec ty1 ty2 ty3) = \n case progress e1 ty1 of\n (Left v1) => case canonicalNat _ ty1 v1 of\n (Left Refl) => let st' = StRecZero\n in Right (_ ** st')\n (Right (e' ** (v', Refl))) => let st' = StRecSucc v1\n in Right (_ ** st')\n (Right (_ ** st1)) => let st' = StRec st1\n in Right (_ ** st')\n-- \nprogress TZero TyZero = Left VZero\n--\nprogress (TSucc e) (TySucc ty) = \n case progress e ty of\n (Left v) => Left $ VSucc v\n (Right (_ ** st)) => let st' = StSucc st\n in Right (_ ** st')\n--\nprogress (TPred e) (TyPred ty) = \n case progress e ty of\n (Left v) => case canonicalNat _ ty v of\n (Left Refl) => let st' = StPredZero\n in Right (TZero ** st')\n (Right (_ ** (v', Refl))) => let st' = StPredSucc v'\n in Right (_ ** st')\n (Right (_ ** st)) => let st' = StPred st\n in Right (_ ** st')\n-- \nprogress (TIfz e1 e2 e3) (TyIfz ty1 ty2 ty3) = \n case progress e1 ty1 of\n (Left v1) => case canonicalNat _ ty1 v1 of\n (Left Refl) => Right (_ ** StIfzZero)\n (Right (_ ** (v1', Refl))) => Right (_ ** StIfzSucc v1')\n (Right (_ ** st)) => let st' = StIfz st\n in Right (_ ** st')\n\n-- End: PROGRESS\n----------------\n\n\n\n\n-------------------------------------------------\n-- Begin: WELL-TYPED IRREDUCIBLE TERMS ARE VALUES\n\nirreducibleValue : (e : Term) ->\n Typing [] e t ->\n ((e' : Term) -> Step e e' -> Void) ->\n Value e\nirreducibleValue e ty nostep = \n case progress e ty of\n (Left v) => v\n (Right (_ ** st)) => absurd $ nostep _ st\n\n-- End: WELL-TYPED IRREDUCIBLE TERMS ARE VALUES\n-----------------------------------------------\n\n\n\n----------------------\n-- Begin: PRESERVATION\n\n-- Preservation: after reducing a term of type 't' by one\n-- step, the resulting term is again of type 't'.\n\npreservation : (e : Term) -> \n Typing ctx e t ->\n Step e e' ->\n Typing ctx e' t\n-- \npreservation (TVar i) (TyVar prf) st impossible\n--\npreservation (TAbs e) (TyAbs s ty) st impossible\n--\npreservation (TApp e1 e2) (TyApp ty1 ty2) (StApp1 st1) =\n let ty1' = preservation e1 ty1 st1\n in TyApp ty1' ty2\npreservation (TApp e1 e2) (TyApp ty1 ty2) (StApp2 v1 st2) = \n let ty2' = preservation e2 ty2 st2\n in TyApp ty1 ty2'\npreservation (TApp (TAbs e) e2) (TyApp ty1 ty2) (StBeta v2) = \n case ty1 of\n (TyAbs s ty1') => substPreservesTy {ctx1=[]} e ty1' e2 ty2\n--\npreservation (TRec e1 e2 e3) (TyRec ty1 ty2 ty3) (StRec st1) = \n let ty1' = preservation e1 ty1 st1\n in TyRec ty1' ty2 ty3\npreservation (TRec TZero e2 e3) (TyRec ty1 ty2 ty3) StRecZero = ty2\npreservation (TRec (TSucc n) e2 e3) (TyRec ty1 ty2 ty3) (StRecSucc v) = \n case ty1 of\n (TySucc tyn) => let tyrn = TyRec tyn ty2 ty3\n tya = TyApp ty3 tyn\n in TyApp tya tyrn\n--\npreservation TZero TyZero st impossible\n--\npreservation (TSucc e) (TySucc ty) (StSucc st) = \n let ty' = preservation e ty st\n in TySucc ty'\n--\npreservation (TPred e) (TyPred ty) (StPred st) = \n let ty' = preservation e ty st\n in TyPred ty'\npreservation (TPred TZero) (TyPred ty) StPredZero = TyZero\npreservation (TPred (TSucc e')) (TyPred ty) (StPredSucc v') = \n case ty of\n (TySucc ty') => ty'\n--\npreservation (TIfz e1 e2 e3) (TyIfz ty1 ty2 ty3) (StIfz st1) = \n let ty1' = preservation e1 ty1 st1\n in TyIfz ty1' ty2 ty3\npreservation (TIfz TZero e2 e3) (TyIfz ty1 ty2 ty3) StIfzZero = ty2\npreservation (TIfz (TSucc n) e2 e3) (TyIfz ty1 ty2 ty3) (StIfzSucc v) = ty3\n\n\n\ntransPreservation : (e : Term) -> \n Typing ctx e t ->\n TransStep e e' ->\n Typing ctx e' t\ntransPreservation e ty (TStRefl e) = ty\ntransPreservation e ty (TStTrans st tst) = \n let ty' = preservation e ty st\n in transPreservation _ ty' tst\n\n-- End: PRESERVATION\n--------------------\n\n", "meta": {"hexsha": "7435971a8df48967f55bde632012f386af4a19ff", "size": 5509, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "totality/src/PnP.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/PnP.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/PnP.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.8439306358, "max_line_length": 88, "alphanum_fraction": 0.4973679434, "num_tokens": 1652, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117769928211, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.5834807894219347}}
{"text": "module Data.AVL.Core\n\nimport public Data.Tree\n\n%default total\n%access export\n\n -- ------------------------------------------------------------- [ Definitions ]\npublic export\ndata Balance : Nat -> Nat -> Type where\n LHeavy : Balance (S n) n\n RHeavy : Balance n (S n)\n Balanced : Balance n n\n\n%name Balance b, bal\n\n||| Indirection ensures that it reduces to at least S n' without\n||| needing to case split on balance.\n|||\n||| Should make proofs easier.\npublic export\nheight : Balance n m -> Nat\nheight b = S (height' b)\n where\n height' : Balance n m -> Nat\n height' (LHeavy {n}) = S n\n height' (RHeavy {n}) = S n\n height' {n} (Balanced {n}) = n\n\n\n||| Encoding of the AVL tree height invariants.\n|||\n||| @height The height of a Tree.\n||| @tree The tree whose height we are capturing.\npublic export\ndata AVLInvariant : (height : Nat)\n -> (tree : Tree k v)\n -> Type\n where\n ||| A tree of height zero.\n AVLEmpty : AVLInvariant 0 Empty\n ||| A Balanced tree.\n |||\n ||| @left The invariant of the left child.\n ||| @right The invariant of the right child.\n ||| @b The encoding of the nodes' balance.\n AVLNode : (left : AVLInvariant n l)\n -> (right : AVLInvariant m r)\n -> (b : Balance n m)\n -> AVLInvariant (height b) (Node k v l r)\n\n%name AVLInvariant inv\n\n||| An AVL Tree.\n|||\n||| Modelled using subset to separate the invariants from the tree\n||| implementation itself.\n|||\n||| @height The height of the Tree.\n||| @keyTy The type associated with the keys.\n||| @valueTy The type associated with the values.\npublic export\nAVLTree : (height : Nat)\n -> (keyTy : Type)\n -> (valueTy : Type)\n -> Type\nAVLTree n k v = Subset (Tree k v) (AVLInvariant n)\n\n-- --------------------------------------------------------------- [ Rotations ]\npublic export\ndata InsertRes : Nat -> (k : Type) -> Type -> Type where\n Same : AVLTree n k v -> InsertRes n k v\n Grew : AVLTree (S n) k v -> InsertRes n k v\n\n%name InsertRes res, r\n\n||| Process the result of an insertion of a new Key-Value pair into\n||| the Tree, returning the new tree and proof of the new tree's\n||| height.\n|||\n||| `InsertRes` is obtained from the result of running `Tree.insert`.\nrunInsertRes : InsertRes n k v -> (n : Nat ** AVLTree n k v)\nrunInsertRes (Same t) = (_ ** t)\nrunInsertRes (Grew t) = (_ ** t)\n\n||| Perform a Left roation.\nrotLeft : k\n -> v\n -> AVLTree n k v\n -> AVLTree (S (S n)) k v\n -> InsertRes (S (S n)) k v\n-- Impossible because Empty has depth 0 and we know the depth is at least 2 from the type\nrotLeft key val l (Element Empty AVLEmpty) impossible\n\nrotLeft key val (Element l invl) (Element (Node key' val' rl rr) (AVLNode invrl invrr Balanced)) =\n Grew $ Element (Node key' val' (Node key val l rl) rr)\n (AVLNode (AVLNode invl invrl RHeavy) invrr LHeavy)\n\nrotLeft key val (Element l invl) (Element (Node key' val' (Node key'' val'' rll rlr) rr) (AVLNode (AVLNode invrll invrlr LHeavy) invrr LHeavy)) =\n Same $ Element (Node key'' val'' (Node key val l rll) (Node key' val' rlr rr)) -- Needs Checking\n (AVLNode (AVLNode invl invrll Balanced) (AVLNode invrlr invrr RHeavy) Balanced)\n\nrotLeft key val (Element l invl) (Element (Node key' val' (Node key'' val'' rll rlr) rr) (AVLNode (AVLNode invrll invrlr RHeavy) invrr LHeavy)) =\n Same $ Element (Node key'' val'' (Node key val l rll) (Node key' val' rlr rr))\n (AVLNode (AVLNode invl invrll LHeavy) (AVLNode invrlr invrr Balanced) Balanced)\n\nrotLeft key val (Element l invl) (Element (Node key' val' (Node key'' val'' rll rlr) rr) (AVLNode (AVLNode invrll invrlr Balanced) invrr LHeavy)) =\n Same $ Element (Node key'' val'' (Node key val l rll) (Node key' val' rlr rr))\n (AVLNode (AVLNode invl invrll Balanced) (AVLNode invrlr invrr Balanced) Balanced) -- Needs Checking\n\nrotLeft key val (Element l invl) (Element (Node key' val' rl rr) (AVLNode invrl invrr RHeavy)) =\n Same $ Element (Node key' val' (Node key val l rl) rr)\n (AVLNode (AVLNode invl invrl Balanced) invrr Balanced)\n\n||| Perform a Right rotation.\nrotRight : k\n -> v\n -> AVLTree (S (S n)) k v\n -> AVLTree n k v\n -> InsertRes (S (S n)) k v\nrotRight key val (Element Empty AVLEmpty) r impossible\n\nrotRight key'' val'' (Element (Node key val ll (Node key' val' lrl lrr))\n (AVLNode invll (AVLNode invlrl invlrr RHeavy) RHeavy)) (Element r invr) =\n Same $ Element (Node key' val' (Node key val ll lrl) (Node key'' val'' lrr r))\n (AVLNode (AVLNode invll invlrl LHeavy) (AVLNode invlrr invr Balanced) Balanced)\n\nrotRight key'' val'' (Element (Node key val ll (Node key' val' lrl lrr))\n (AVLNode invll (AVLNode invlrl invlrr LHeavy) RHeavy)) (Element r invr) =\n Same $ Element (Node key' val' (Node key val ll lrl) (Node key'' val'' lrr r))\n (AVLNode (AVLNode invll invlrl Balanced) (AVLNode invlrr invr RHeavy) Balanced)\n\nrotRight key val (Element (Node key' val' ll lr) (AVLNode invll invlr Balanced)) (Element r invr) =\n Grew $ Element (Node key' val' ll (Node key val lr r))\n (AVLNode invll (AVLNode invlr invr LHeavy) RHeavy)\n\nrotRight key val (Element (Node key' val' ll lr) (AVLNode invll invlr LHeavy)) (Element r invr) =\n Same $ Element (Node key' val' ll (Node key val lr r))\n (AVLNode invll (AVLNode invlr invr Balanced) Balanced)\n\nrotRight key val (Element (Node key' val' ll (Node key'' val'' lrl lrr))\n (AVLNode invll (AVLNode invlrl invlrr Balanced) RHeavy)) (Element r invr) =\n Same $ Element (Node key'' val'' (Node key' val' ll lrl) (Node key val lrr r))\n (AVLNode (AVLNode invll invlrl Balanced) (AVLNode invlrr invr Balanced) Balanced)\n\n\n --------------------------------------------------------------- [ Insertion ]\n\n||| Perform an insertion into the tree returning the new tree wrapped\n||| in a description describing the height change.\ndoInsert : (Ord k)\n => k\n -> v\n -> AVLTree n k v\n -> InsertRes n k v\ndoInsert newKey newVal (Element Empty AVLEmpty) = Grew (Element (Node newKey newVal Empty Empty)\n (AVLNode AVLEmpty AVLEmpty Balanced))\ndoInsert newKey newVal (Element (Node key val l r) (AVLNode invl invr b)) with (compare newKey key)\n doInsert newKey newVal (Element (Node key val l r) (AVLNode invl invr b)) | EQ = Same (Element (Node newKey newVal l r) (AVLNode invl invr b))\n\n doInsert newKey newVal (Element (Node key val l r) (AVLNode invl invr b)) | LT with (assert_total $ doInsert newKey newVal (Element l invl))\n -- Totality checker not clever enough to see that this is smaller\n doInsert newKey newVal (Element (Node key val l r) (AVLNode invl invr b)) | LT | (Same (Element l' invl'))\n = Same $ Element (Node key val l' r) (AVLNode invl' invr b)\n doInsert newKey newVal (Element (Node key val l r) (AVLNode invl invr LHeavy)) | LT | (Grew (Element l' invl'))\n = rotRight key val (Element l' invl') (Element r invr)\n doInsert newKey newVal (Element (Node key val l r) (AVLNode invl invr Balanced)) | LT | (Grew (Element l' invl'))\n = Grew $ Element (Node key val l' r) (AVLNode invl' invr LHeavy)\n doInsert newKey newVal (Element (Node key val l r) (AVLNode invl invr RHeavy)) | LT | (Grew (Element l' invl'))\n = Same $ Element (Node key val l' r) (AVLNode invl' invr Balanced)\n\n doInsert newKey newVal (Element (Node key val l r) (AVLNode invl invr b)) | GT with (assert_total $ doInsert newKey newVal (Element r invr))\n -- Totality checker not clever enough to see that this is smaller\n doInsert newKey newVal (Element (Node key val l r) (AVLNode invl invr b)) | GT | (Same (Element r' invr'))\n = Same $ Element (Node key val l r') (AVLNode invl invr' b)\n doInsert newKey newVal (Element (Node key val l r) (AVLNode invl invr LHeavy)) | GT | (Grew (Element r' invr'))\n = Same $ Element (Node key val l r') (AVLNode invl invr' Balanced)\n doInsert newKey newVal (Element (Node key val l r) (AVLNode invl invr Balanced)) | GT | (Grew (Element r' invr'))\n = Grew $ Element (Node key val l r') (AVLNode invl invr' RHeavy)\n doInsert newKey newVal (Element (Node key val l r) (AVLNode invl invr RHeavy)) | GT | (Grew (Element r' invr'))\n = rotLeft key val (Element l invl) (Element r' invr')\n\n||| Insert a key value pair into the tree, returning a the new tree\n||| and possibly its new height.\ninsert : Ord k => k -> v -> AVLTree n k v -> (n : Nat ** AVLTree n k v)\ninsert k v t = runInsertRes (doInsert k v t)\n", "meta": {"hexsha": "ae1ab6067bd8e65fc022ddf045c9873d6e7f4638", "size": 9411, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Data/AVL/Core.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/AVL/Core.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/AVL/Core.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": 50.3262032086, "max_line_length": 156, "alphanum_fraction": 0.5796408458, "num_tokens": 2648, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.863391617003942, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.5834494915878592}}
{"text": "import Data.Nat\n\np1_equals_s : (1+) = S\np1_equals_s = Refl\n\nfunext : {p, q : a -> b} -> ((x : a) -> p x = q x) -> p = q\nfunext _ = believe_me (Z = Z)\n\nonep_equals_s : (+1) = S\nonep_equals_s = funext \\x => plusCommutative x 1\n", "meta": {"hexsha": "2ebd7d0d1f1b8dbd4b738e7c39ac04f77baaf03c", "size": 225, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Plus1.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": "Plus1.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": "Plus1.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": 20.4545454545, "max_line_length": 59, "alphanum_fraction": 0.5777777778, "num_tokens": 94, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9005297807787536, "lm_q2_score": 0.6477982315512488, "lm_q1q2_score": 0.5833615994477104}}
{"text": "module Data.Tree.Perfect\n\nimport Control.WellFounded\nimport Decidable.Order.Strict\nimport Data.Monoid.Exponentiation\nimport Data.Num.Implementations\nimport Data.Nat.Views\nimport Data.Nat\nimport Data.Nat.Order\nimport Data.Nat.Order.Strict\nimport Data.Nat.Order.Properties\nimport Data.Nat.Exponentiation\nimport Data.DPair\nimport Syntax.WithProof\nimport Syntax.PreorderReasoning.Generic\n\n%default total\n\npublic export\ndata Tree : Nat -> Type -> Type where\n Leaf : a -> Tree Z a\n Node : Tree n a -> Tree n a -> Tree (S n) a\n\npublic export\nFunctor (Tree n) where\n map f (Leaf a) = Leaf (f a)\n map f (Node l r) = Node (map f l) (map f r)\n\npublic export\nreplicate : (n : Nat) -> a -> Tree n a\nreplicate Z a = Leaf a\nreplicate (S n) a = let t = replicate n a in Node t t\n\npublic export\n{n : _} -> Applicative (Tree n) where\n pure = replicate n\n\n Leaf f <*> Leaf a = Leaf (f a)\n Node fl fr <*> Node xl xr = Node (fl <*> xl) (fr <*> xr)\n\npublic export\ndata Path : Nat -> Type where\n Here : Path Z\n Left : Path n -> Path (S n)\n Right : Path n -> Path (S n)\n\npublic export\ntoNat : {n : _} -> Path n -> Nat\ntoNat Here = Z\ntoNat (Left p) = toNat p\ntoNat {n = S n} (Right p) = toNat p + pow2 n\n\nexport\ntoNatBounded : (n : Nat) -> (p : Path n) -> toNat p `LT` pow2 n\ntoNatBounded Z Here = reflexive {rel = LTE}\ntoNatBounded (S n) (Left p) = CalcWith $\n |~ S (toNat p)\n <~ pow2 n ...( toNatBounded n p )\n <~ pow2 n + pow2 n ...( lteAddRight (pow2 n) )\n ~~ pow2 (S n) ...( sym unfoldPow2 )\ntoNatBounded (S n) (Right p) = CalcWith $\n let ih = toNatBounded n p in\n |~ S (toNat p) + pow2 n\n <~ pow2 n + pow2 n ...( plusLteMonotoneRight _ _ _ ih )\n ~~ pow2 (S n) ...( sym unfoldPow2 )\n\nnamespace FromNat\n\n ||| This pattern-matching in `fromNat` is annoying:\n ||| The `Z (S _)` case is impossible\n ||| In the `k (S n)` case we want to branch on whether `k `LT` pow2 n`\n ||| and get our hands on some proofs.\n ||| This view factors out that work.\n public export\n data View : (k, n : Nat) -> Type where\n ZZ : View Z Z\n SLT : (0 p : k `LT` pow2 n) -> View k (S n)\n SNLT : (0 p : k `GTE` pow2 n) ->\n (0 rec : minus k (pow2 n) `LT` pow2 n) -> View k (S n)\n\n public export\n view : (k, n : Nat) -> (0 _ : k `LT` (pow2 n)) -> View k n\n view Z Z p = ZZ\n view (S _) Z p = void $ absurd (fromLteSucc p)\n view k (S n) p with (@@ lt k (pow2 n))\n view k (S n) p | (True ** eq) = SLT (ltIsLT k (pow2 n) eq)\n view k (S n) p | (False ** eq) = SNLT gte prf where\n\n 0 gte : k `GTE` pow2 n\n gte = notLTImpliesGTE (notltIsNotLT k (pow2 n) eq)\n\n 0 prf : minus k (pow2 n) `LT` pow2 n\n prf = CalcWith $\n |~ S (minus k (pow2 n))\n <~ minus (pow2 (S n)) (pow2 n)\n ...( minusLtMonotone p pow2Increasing )\n ~~ minus (pow2 n + pow2 n) (pow2 n)\n ...( cong (\\ m => minus m (pow2 n)) unfoldPow2 )\n ~~ pow2 n\n ...( minusPlus (pow2 n) )\n\n||| Convert a natural number to a path in a perfect binary tree\npublic export\nfromNat : (k, n : Nat) -> (0 _ : k `LT` pow2 n) -> Path n\nfromNat k n p with (view k n p)\n fromNat Z Z p | ZZ = Here\n fromNat k (S n) p | SLT lt = Left (fromNat k n lt)\n fromNat k (S n) p | SNLT _ lt = Right (fromNat (minus k (pow2 n)) n lt)\n\n||| The `fromNat` conversion is compatible with the semantics `toNat`\nexport\nfromNatCorrect : (k, n : Nat) -> (0 p : k `LT` pow2 n) ->\n toNat (fromNat k n p) === k\nfromNatCorrect k n p with (view k n p)\n fromNatCorrect Z Z p | ZZ = Refl\n fromNatCorrect k (S n) p | SLT lt = fromNatCorrect k n lt\n fromNatCorrect k (S n) p | SNLT gte lt\n = rewrite fromNatCorrect (minus k (pow2 n)) n lt in\n irrelevantEq $ plusMinusLte (pow2 n) k gte\n\npublic export\nlookup : Tree n a -> Path n -> a\nlookup (Leaf a) Here = a\nlookup (Node l _) (Left p) = lookup l p\nlookup (Node _ r) (Right p) = lookup r p\n", "meta": {"hexsha": "e2f9119d23b11d3ab07a4ec28639df990c230f56", "size": 3890, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/contrib/Data/Tree/Perfect.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/Tree/Perfect.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/Tree/Perfect.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.873015873, "max_line_length": 73, "alphanum_fraction": 0.5966580977, "num_tokens": 1366, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672135527632, "lm_q2_score": 0.7217432122827968, "lm_q1q2_score": 0.5832170264499801}}
{"text": "> module Fun.Properties\n\n> import Syntax.PreorderReasoning\n\n> import Fun.Operations\n> import Fun.Predicates\n> import Pair.Properties\n> import Finite.Predicates\n\n\n> %default total\n> %access public export\n> %auto_implicits on\n\n\n> ||| Functionality of dependent functions \n> functionality : {A : Type} -> {B : A -> Type} -> \n> {f : (a : A) -> B a} -> {g : (a : A) -> B a} -> \n> f = g -> (a : A) -> f a = g a\n> functionality Refl x = Refl\n\n> ||| Injectivity (one direction)\n> Injective1 : {A, B : Type} -> (f : A -> B) -> Type\n> Injective1 {A} f = (a1 : A) -> (a2 : A) -> f a1 = f a2 -> a1 = a2\n\n\n> ||| Injectivity (the other direction)\n> Injective2 : {A, B : Type} -> (f : A -> B) -> Type\n> Injective2 {A} f = (a1 : A) -> (a2 : A) -> Not (a1 = a2) -> Not (f a1 = f a2)\n\n\n> ||| Non injectivity, constructive\n> NonInjective : {A, B : Type} -> (f : A -> B) -> Type\n> NonInjective f = Exists (\\ a1 => Exists (\\ a2 => (Not (a1 = a2) , f a1 = f a2)))\n\n\n> ||| Surjectivity\n> Surjective : {A, B : Type} -> (f : A -> B) -> Type\n> Surjective {B} f = (b : B) -> Exists (\\ a => f a = b)\n\n\n> ||| Non surjectivity, constructive\n> NonSurjective : {A, B : Type} -> (f : A -> B) -> Type\n> NonSurjective {A} f = Exists (\\ b => (a : A) -> Not (f a = b))\n\n\nRelationships of injectivity notions\n\n> ||| Injective1 implies Injective2\n> injectiveLemma : {A, B : Type} -> (f : A -> B) -> Injective1 f -> Injective2 f\n> injectiveLemma f i1f a1 a2 contra = contra . (i1f a1 a2)\n> %freeze injectiveLemma -- frozen\n\n\nProperties of constructive proofs\n\n> ||| NonInjective => Not Injective\n> nonInjectiveNotInjective : {A, B : Type} -> (f : A -> B) -> NonInjective f -> Not (Injective1 f)\n> nonInjectiveNotInjective f (Evidence a1 (Evidence a2 (na1eqa2 , fa1eqfa2))) =\n> \\ injectivef => na1eqa2 (injectivef a1 a2 fa1eqfa2)\n> %freeze nonInjectiveNotInjective -- frozen\n\n\n> ||| NonSurjective => Not Surjective\n> nonSurjectiveNotSurjective : {A, B : Type} -> (f : A -> B) -> NonSurjective f -> Not (Surjective f)\n> nonSurjectiveNotSurjective f (Evidence b faanfab) =\n> \\ surjectivef => let a = (getWitness (surjectivef b)) in (faanfab a) (getProof (surjectivef b))\n> %freeze nonSurjectiveNotSurjective -- frozen\n\n\nProperties of cross\n\n> |||\n> crossAnyIdFstLemma : fst ((cross f Prelude.Basics.id) (a,b)) = f a\n> crossAnyIdFstLemma {a} {b} {f} = Refl\n\n\n> |||\n> crossAnyIdFstLemma' : fst ((cross f Prelude.Basics.id) ab) = f (fst ab)\n> crossAnyIdFstLemma' {ab} {f} = \n> ( fst ((cross f Prelude.Basics.id) ab) )\n> ={ cong {f = \\ ZUZU => fst ((cross f Prelude.Basics.id) ZUZU)} (pairLemma ab) }=\n> ( fst ((cross f Prelude.Basics.id) (fst ab, snd ab)) )\n> ={ Refl }=\n> ( fst (f (fst ab), id (snd ab)) )\n> ={ Refl }=\n> ( f (fst ab) )\n> QED\n\n\n> |||\n> crossAnyIdSndLemma : snd ((cross f Prelude.Basics.id) (a,b)) = b\n> crossAnyIdSndLemma {a} {b} {f} = Refl\n\n\n> |||\n> crossAnyIdSndLemma' : snd ((cross f Prelude.Basics.id) ab) = snd ab\n> crossAnyIdSndLemma' {ab} {f} = \n> ( snd ((cross f Prelude.Basics.id) ab) )\n> ={ cong {f = \\ ZUZU => snd ((cross f Prelude.Basics.id) ZUZU)} (pairLemma ab) }=\n> ( snd ((cross f Prelude.Basics.id) (fst ab, snd ab)) )\n> ={ Refl }=\n> ( snd (f (fst ab), id (snd ab)) )\n> ={ Refl }=\n> ( snd (f (fst ab), snd ab) )\n> ={ Refl }=\n> ( snd ab )\n> QED\n\n\n> |||\n> crossIdAnyFstLemma : fst ((cross Prelude.Basics.id f) (a,b)) = a\n> crossIdAnyFstLemma {a} {b} {f} = Refl\n\n\n* Properties of extensional equality\n\n> {-\n> finiteDecidableExtEq : {A, B : Type} -> \n> (f : A -> B) -> (g : A -> B) -> \n> Finite A -> DecEq B -> Dec (ExtEq f g)\n> -}\n\n\n\n> {-\n\n> ---}\n", "meta": {"hexsha": "bf2d6a4ed8aae2a0a8881ae8c546eaa1c83624d5", "size": 3668, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "Fun/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": "Fun/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": "Fun/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": 28.4341085271, "max_line_length": 101, "alphanum_fraction": 0.5662486369, "num_tokens": 1321, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743505760728, "lm_q2_score": 0.7879312056025699, "lm_q1q2_score": 0.5832064684055043}}
{"text": "module QuantumOp\n\nimport Data.Vect\nimport Data.Nat\nimport Decidable.Equality\nimport System.File\nimport Injection\nimport Matrix\nimport Complex\nimport System.Random\nimport Lemmas\nimport QStateT\nimport Control.Linear.LIO\nimport LinearTypes\nimport Unitary\n\n||| The Qubit type is used to identify individual qubits. The Nat argument is\n||| used to uniquely identify a qubit. This type does *not* carry any quantum\n||| state information. The constructor MkQubit is *private* in order to prevent\n||| pattern matching by users of the library.\nexport\ndata Qubit : Type where\n MkQubit : (n : Nat) -> Qubit\n\n||| The QuantumOp interface is used to abstract over the representation of a\n||| quantum state. It is parameterised by the number of qubits it contains.\nexport\ninterface QuantumOp (0 t : Nat -> Type) where\n\n ||| Prepare 'p' new qubits in state |00...0>\n newQubits : (p : Nat) -> QStateT (t n) (t (n+p)) (LVect p Qubit)\n newQubits Z = rewrite plusZeroRightNeutral n in pure []\n newQubits (S k) = rewrite lemmaPlusSRight n k in do\n q <- newQubit\n qs <- newQubits k\n pure (q :: qs)\n\n ||| Prepare a single new qubit in state |0>\n newQubit : QStateT (t n) (t (S n)) Qubit\n newQubit = rewrite sym $ lemmaplusOneRight n in do\n [q] <- newQubits 1\n pure q\n\n ||| Apply a unitary circuit to the qubits specified by the LVect argument\n applyUnitary : {n : Nat} -> {i : Nat} ->\n (1 _ : LVect i Qubit) -> Unitary i -> QStateT (t n) (t n) (LVect i Qubit)\n\n ||| Apply the Hadamard gate to a single qubit\n applyH : {n : Nat} -> (1 _ : Qubit) -> QStateT (t n) (t n) Qubit\n applyH q = do\n [q1] <- applyUnitary {n} {i = 1} [q] HGate \n pure q1\n\n ||| Apply a P gate to a single qubit\n applyP : {n : Nat} -> Double -> (1 _ : Qubit) -> QStateT (t n) (t n) Qubit\n applyP p q = do\n [q1] <- applyUnitary {n} {i = 1} [q] (PGate p)\n pure q1\n\n ||| Apply the CNOT gate to a pair of qubits\n applyCNOT : {n : Nat} -> (1 _ : Qubit) -> (1 _ : Qubit) -> QStateT (t n) (t n) (LPair Qubit Qubit)\n applyCNOT q1 q2 = do\n [q1,q2] <- applyUnitary {n} {i = 2} [q1,q2] CNOTGate\n pure (q1 # q2)\n\n ||| Measure some qubits in a quantum state\n public export\n measure : {n : Nat} -> {i : Nat} -> (1 _ : LVect i Qubit) -> QStateT (t (i + n)) (t n) (Vect i Bool)\n measure [] = pure []\n measure (q :: qs) = do\n b <- measureQubit q\n bs <- measure qs\n pure (b `consLin` bs)\n\n ||| Measure only one qubit\n measureQubit : {n : Nat} -> (1 _ : Qubit) -> QStateT (t (S n)) (t n) Bool\n measureQubit q = do\n [b] <- measure [q]\n pure b\n\n ||| Same as measure, but with an initial state of n + i instead of i + n qubits to help with theorem proving in some cases\n -- public export\n -- measure2 : {n : Nat} -> {i : Nat} -> (LVect i Qubit) -> QStateT (t (n + i)) (t n) (Vect i Bool)\n -- measure2 v = rewrite plusCommutative n i in measure v\n\n ||| Measure all qubits in a quantum state\n ||| Because of a bug in Idris2, we use the implementation below.\n ||| However, the implementation commented out is preferable if the bug gets fixed.\n public export\n measureAll : {n : Nat} -> (1 _ : LVect n Qubit) -> QStateT (t n) (t 0) (Vect n Bool)\n measureAll [] = pure []\n measureAll (q :: qs) = do\n b <- measureQubit q\n bs <- measureAll qs\n pure (b `consLin` bs)\n --measureAll qs = rewrite sym $ plusZeroRightNeutral n in measure qs\n \n ||| Execute a quantum operation : start and finish with trivial quantum state\n ||| (0 qubits) and measure 'n' qubits in the process\n run : QStateT (t 0) (t 0) (Vect n Bool) -> IO (Vect n Bool)\n\n\n\n\n\n----- IMPLEMENTATION OF QUANTUMSTATE: LINEAR-ALGEBRAIC SIMULATION -----------\n\n\n||| SimulatedOp : linear-algebraic vector representation of the quantum state, vector of indices of the qubits, counter\nexport\ndata SimulatedOp : Nat -> Type where\n MkSimulatedOp : {n : Nat} -> Matrix (power 2 n) 1 -> Vect n Qubit -> Nat -> SimulatedOp n\n\n------ SIMULATION : AUXILIARY (PRIVATE) FUNCTIONS ------\n\n\n||| Find an element in a list : used to find the wire of a qubit\nprivate\nlistIndex' : {n : Nat} -> Vect n Qubit -> Qubit -> Nat\nlistIndex' [] _ = 0\nlistIndex' (MkQubit x :: xs) (MkQubit k) = if x == k then 0 else S (listIndex' xs (MkQubit k))\n\nprivate\nlistIndex : (1 _ : SimulatedOp n) -> (1 _ : Qubit) -> LFstPair (LPair (SimulatedOp n) Qubit) Nat\nlistIndex (MkSimulatedOp qs v counter) (MkQubit k) = (MkSimulatedOp qs v counter # MkQubit k) # (listIndex' v (MkQubit k))\n\nprivate \nlistIndices : (1 _ : SimulatedOp n) -> (1 _ : LVect i Qubit) -> LFstPair (LPair (SimulatedOp n) (LVect i Qubit)) (Vect i Nat)\nlistIndices qs [] = (qs # []) # []\nlistIndices qs (x :: xs) = \n let (qs' # x') # y = listIndex qs x\n (qs2 # xs') # ys = listIndices qs' xs\n in (qs2 # (x' :: xs')) # (y :: ys)\n\n||| Remove an element at a given index in the vector\nprivate \nremoveElem : {n : Nat} -> Vect (S n) Qubit -> Nat -> Vect n Qubit\nremoveElem (x :: xs) 0 = xs\nremoveElem (x :: xs) (S k) = case xs of\n [] => []\n y :: ys => x :: removeElem xs k\n\n\n||| add the indices of the new qubits to the vector in the SimulatedOp\nprivate \nnewQubitsPointers : (p : Nat) -> (counter : Nat) -> LFstPair (LVect p Qubit) (Vect p Qubit)\nnewQubitsPointers 0 _ = ([] # [])\nnewQubitsPointers (S p) counter = \n let (q # v) = newQubitsPointers p (S counter)\n in (MkQubit counter :: q) # (MkQubit counter :: v)\n\n||| Auxiliary function for applying a circuit to some qubits\nprivate\napplyUnitary' : {n : Nat} -> {i : Nat} ->\n (1 _ : LVect i Qubit) -> Unitary i -> (1 _ : SimulatedOp n) -> R (LPair (SimulatedOp n) (LVect i Qubit))\napplyUnitary' v u q = \n let (qs # v') # ind = listIndices q v \n qs2 = applyCirc ind u qs\n in pure1 (qs2 # v') where\n applyCirc : Vect i Nat -> Unitary i -> (1 _ : SimulatedOp n) -> SimulatedOp n\n applyCirc v IdGate qst = qst\n applyCirc v (H j g) st = \n let k = index j v \n h = simpleTensor matrixH n k\n MkSimulatedOp qst q counter = applyCirc v g st\n in MkSimulatedOp (h `matrixMult` qst) q counter\n applyCirc v (P p j g) st = \n let k = index j v\n ph = simpleTensor (matrixP p) n k\n MkSimulatedOp qst q counter = applyCirc v g st\n in MkSimulatedOp (ph `matrixMult` qst) q counter\n applyCirc v (CNOT c t g) st = \n let kc = index c v\n kt = index t v\n cn = tensorCNOT n kc kt\n MkSimulatedOp qst q counter = applyCirc v g st\n in MkSimulatedOp (cn `matrixMult` qst) q counter\n\n\n||| Auxiliary function for measurements\nprivate\nmeasure' : {n : Nat} -> (i : Nat) ->\n (1 _ : SimulatedOp (S n)) ->\n R (LFstPair (SimulatedOp n) Bool)\nmeasure' {n} i (MkSimulatedOp v w counter) = do\n let projector0 = simpleTensor matrixKet0Bra0 (S n) i\n let projection0 = projector0 `matrixMult` v\n let norm20 = normState2 projection0\n let projector1 = simpleTensor matrixKet1Bra1 (S n) i\n let projection1 = projector1 `matrixMult` v\n let norm21 = normState2 projection1\n let newQubits = removeElem w i\n randnb <- liftIO1 randomIO\n if randnb < norm20\n then do\n let proj = multScalarMatrix (inv (sqrt norm20) :+ 0) projection0\n pure1 (MkSimulatedOp (projectState {n} proj i False) newQubits counter # False)\n else do\n let proj = multScalarMatrix (inv (sqrt norm21) :+ 0) projection1\n pure1 (MkSimulatedOp (projectState {n} proj i True) newQubits counter # True)\n\n||| Auxiliary function for measurements\nprivate\nmeasureQubits' : {n : Nat} -> {i : Nat} ->\n (1 _ : LVect i Qubit) ->\n (1 _ : SimulatedOp (i + n)) -> R (LPair (SimulatedOp n) (Vect i Bool))\nmeasureQubits' [] qs = pure1 (qs # [])\nmeasureQubits' (x :: xs) qs = do\n let (qs' # (MkQubit k)) # y = listIndex qs x\n (s # b) <- measure' y qs'\n (s1 # bs) <- measureQubits' xs s\n case bs of \n [] => pure1 (s1 # [b])\n (b' :: bs') => pure1 (s1 # (b :: b' :: bs'))\n\n------- SIMULATE CIRCUITS : OPERATIONS ON QUANTUM STATES ------\n\n\n||| Add new qubits to a Quantum State\nexport\nnewQubitsSimulated : (p : Nat) -> QStateT (SimulatedOp n) (SimulatedOp (n+p)) (LVect p Qubit)\nnewQubitsSimulated p = MkQST (newQubits' p) where\n newQubits' : (q : Nat) -> (1 _ : SimulatedOp m) -> R (LPair (SimulatedOp (m + q)) (LVect q Qubit))\n newQubits' q (MkSimulatedOp qs v counter) =\n let s' = toTensorBasis (ket0 q)\n (qubits # v') = newQubitsPointers q counter\n in pure1 (MkSimulatedOp (tensorProductVect qs s') (v ++ v') (counter + q) # qubits)\n\n\n||| Apply a unitary circuit to a SimulatedOp\nexport\napplyUnitarySimulated : {n : Nat} -> {i : Nat} ->\n (1 _ : LVect i Qubit) -> Unitary i -> QStateT (SimulatedOp n) (SimulatedOp n) (LVect i Qubit)\napplyUnitarySimulated q u = MkQST (applyUnitary' q u)\n\n||| Measure some qubits in a quantum state\nexport\nmeasureSimulated : {n : Nat} -> {i : Nat} -> (1 _ : LVect i Qubit) -> QStateT (SimulatedOp (i + n)) (SimulatedOp n) (Vect i Bool)\nmeasureSimulated v = MkQST (measureQubits' v)\n\n||| Run all simulations : start with 0 qubit and measure all qubits at the end (end with 0 qubit)\nexport\nrunSimulated : QStateT (SimulatedOp 0) (SimulatedOp 0) (Vect n Bool) -> IO (Vect n Bool)\nrunSimulated s = LIO.run (do\n ((MkSimulatedOp st w c) # v) <- runQStateT (MkSimulatedOp [[1]] [] 0) s\n case v of \n [] => pure []\n (x :: xs) => pure (x :: xs))\n \nexport\nQuantumOp SimulatedOp where\n newQubits = newQubitsSimulated\n applyUnitary = applyUnitarySimulated\n measure = measureSimulated\n run = runSimulated\n", "meta": {"hexsha": "41eefec18a13e50cebec3fc9f1e625b80f6664c4", "size": 9602, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "QuantumOp.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": "QuantumOp.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": "QuantumOp.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": 37.5078125, "max_line_length": 129, "alphanum_fraction": 0.6247656738, "num_tokens": 3210, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.885631470799559, "lm_q2_score": 0.6584174938590245, "lm_q1q2_score": 0.5831152534865274}}
{"text": "module SmallStepStackMachine\n\nimport Expr\nimport Logic\nimport Maps\nimport SmallStepExpr\n\n%access public export\n\n%default total\n\ndata SInstr : Type where\n SPush : (n : Nat) -> SInstr\n SLoad : (x : Id) -> SInstr\n SPlus : SInstr\n SMinus : SInstr\n SMult : SInstr\n\nStack : Type\nStack = List Nat\n\nProg : Type\nProg = List SInstr\n\ndata StackStep : State -> (Prog, Stack) -> (Prog, Stack) -> Type where\n SS_Push : StackStep st (SPush n :: p', stk) (p', n :: stk)\n SS_Load : StackStep st (SLoad x :: p', stk) (p', st x :: stk)\n SS_Plus : StackStep st (SPlus :: p', n :: m :: stk) (p', m + n :: stk)\n SS_Minus : StackStep st (SMinus :: p', n :: m :: stk) (p', minus m n :: stk)\n SS_Mult : StackStep st (SMult :: p', n :: m :: stk) (p', m * n :: stk)\n\nstack_deterministic : Deterministic (StackStep st)\nstack_deterministic SS_Push SS_Push = Refl\nstack_deterministic SS_Load SS_Load = Refl\nstack_deterministic SS_Plus SS_Plus = Refl\nstack_deterministic SS_Minus SS_Minus = Refl\nstack_deterministic SS_Mult SS_Mult = Refl\n\nStackMultiStep : (st : State) -> Relation (Prog, Stack)\nStackMultiStep st = Multi (StackStep st)\n\ns_compile : (e : AExp) -> Prog\ns_compile (ANum k) = [SPush k]\ns_compile (AId x) = [SLoad x]\ns_compile (APlus x y) = s_compile x ++ s_compile y ++ [SPlus]\ns_compile (AMinus x y) = s_compile x ++ s_compile y ++ [SMinus]\ns_compile (AMult x y) = s_compile x ++ s_compile y ++ [SMult]\n\ncompiler_is_correct : AStep st e (ANum n) ->\n Multi (StackStep st) (s_compile e, stk) ([], n :: stk)\ncompiler_is_correct AS_Id = MultiStep SS_Load MultiRefl\ncompiler_is_correct AS_Plus =\n MultiStep SS_Push $\n MultiStep SS_Push $\n MultiStep SS_Plus $\n MultiRefl\ncompiler_is_correct AS_Minus =\n MultiStep SS_Push $\n MultiStep SS_Push $\n MultiStep SS_Minus $\n MultiRefl\ncompiler_is_correct AS_Mult =\n MultiStep SS_Push $\n MultiStep SS_Push $\n MultiStep SS_Mult $\n MultiRefl\n", "meta": {"hexsha": "7cc968ba301020b7dcd4144b8fd7dacfdea01362", "size": 1902, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "SmallStepStackMachine.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": "SmallStepStackMachine.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": "SmallStepStackMachine.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": 28.3880597015, "max_line_length": 78, "alphanum_fraction": 0.6855941115, "num_tokens": 614, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711870587667, "lm_q2_score": 0.6859494550081926, "lm_q1q2_score": 0.5830372725356275}}
{"text": "module Zoo\n\ndata SourcePos = SP String Nat Nat\nShow SourcePos where\n show (SP x k j) = x ++ \":\" ++ (show k) ++ \",\" ++ (show j)\n\nName : Type\nName = String\n\nmutual\n Ty : Type\n Ty = Tm\n\n RRaw : Type\n RRaw = Tm\n\n data Tm\n = Var Name\n | Lam Name Tm\n | App Tm Tm\n | U\n | Pi Name Ty Ty\n | Let Name Ty Tm Tm\n | SrcPos SourcePos Tm\n%name Tm t, u\n\ndata Val\n = VVar Name\n | VApp Val Val\n | VLam Name (Val -> Val)\n | VPi Name Val (Val -> Val)\n | VU\n\nEnv : Type\nEnv = List (Name, Maybe Val)\n%name Env env, env1, env2, env3\n\nfresh : Env -> Name -> Name\nfresh env \"_\" = \"_\"\nfresh [] x = x\nfresh (y :: xs) x = case x == fst y of\n False => fresh xs x\n True => fresh xs (x ++ \"'\")\n\n-- maybe (VVar x) id (fromJust $ lookup x env)\n\npartial\neval : Env -> Tm -> Val\neval env (Var x) = let findX = lookup x env in\n (case findX of\n Nothing => VVar x\n (Just x') => (case x' of\n Nothing => VVar x\n (Just x'') => x''))\neval env (App t u) = case (eval env t, eval env u) of\n (VLam _ t', u') => t' u'\n (t', u') => VApp t' u'\neval env (Lam x t) = VLam x (\\u => eval ((x, Just u) :: env) t)\neval env (Pi x a b) = VPi x (eval env a) (\\u => eval ((x, Just u) :: env) b)\neval env (Let x _ t u) = eval ((x, Just (eval env t)) :: env) u\neval env U = VU\neval env (SrcPos _ t) = eval env t\n\npartial\nquote : Env -> Val -> Tm\nquote env (VVar x) = Var x\nquote env (VApp t u) = App (quote env t) (quote env u)\nquote env VU = U\nquote env (VPi x a b) = let freshX = fresh env x in\n Pi x (quote env a) (quote ((x, Nothing) :: env) (b (VVar x)))\nquote env (VLam x t) = let freshX = fresh env x in\n Lam x (quote ((x, Nothing) :: env) (t (VVar x)))\n\npartial\nnf : Env -> Tm -> Tm\nnf env = quote env . eval env\n\npartial\nnf0 : Tm -> Tm\nnf0 = nf []\n\npartial\nconv : Env -> Val -> Val -> Bool\nconv env t u =\n case (t, u) of\n (VU, VU) => True\n (VPi x a b, VPi x' a' b') =>\n let gx = fresh env x in\n conv env a a' && conv ((gx, Nothing) :: env) (b (VVar gx)) (b' (VVar gx))\n (VLam x t, VLam x' t') =>\n let gx = fresh env x in\n conv ((gx, Nothing) :: env) (t (VVar gx)) (t' (VVar gx))\n\n -- checking eta conversion for Lam\n (VLam x t, u) =>\n let gx = fresh env x in\n conv ((gx, Nothing) :: env) (t (VVar gx)) (VApp u (VVar gx))\n (u, VLam x t) =>\n let gx = fresh env x in\n conv ((gx, Nothing) :: env) (VApp u (VVar gx)) (t (VVar gx))\n\n (VVar x, VVar x') => x == x'\n (VApp t u, VApp t' u') => conv env t t' && conv env u u'\n _ => False\n\nVTy : Type\nVTy = Val\n\nCxt : Type\nCxt = List (Name, VTy)\n\nM : Type -> Type\nM = Either (String, Maybe SourcePos)\n\nreport : String -> M a\nreport str = Left (str, Nothing)\n\nquoteShow : Env -> Val -> String\n\naddPos : SourcePos -> M a -> M a\naddPos pos ma = case ma of\n Left (msg, Nothing) => Left (msg, Just pos)\n x => x\n\nmutual\n partial\n infer : Env -> Cxt -> RRaw -> M VTy\n infer env cxt (Var x) =\n case lookup x cxt of\n Nothing => report $ \"Name not in scope: \" ++ x\n Just a => Right a\n infer env cxt (Lam _ _) = report \"Can't infer type for lambda expresion\"\n infer env cxt (App t u) =\n do tty <- infer env cxt t\n (case tty of\n (VPi _ a b) =>\n do check env cxt u a\n Right (b (eval env u))\n _ => report $\n \"Expected a function type, instead inferred:\\n\\n \"\n ++ quoteShow env tty)\n infer env cxt U = Right VU\n infer env cxt (Pi x a b) =\n do Zoo.check env cxt a VU\n check ((x, Nothing) :: env) ((x, eval env a) :: cxt) b VU\n Right VU\n infer env cxt (Let x a t u) =\n let a' = eval env a in -- TODO not sure about\n do check env cxt a VU\n check env cxt t a'\n infer ((x, Just (eval env t)) :: env) ((x, a') :: cxt) u\n infer env cxt (SrcPos pos t) = addPos pos (infer env cxt t)\n\n partial\n check : Env -> Cxt -> RRaw -> VTy -> M ()\n check env cxt t a =\n case (t, a) of\n (SrcPos pos t', _) => addPos pos (check env cxt t' a)\n (Lam x t, VPi x' a b) =>\n let freshX' = fresh env x' in\n check ((x, Just (VVar freshX')) :: env) ((x, a) :: cxt) t (b (VVar x'))\n (Let x a' t' u, _) => -- TODO not sure about this one\n let a'' = eval env a' in\n do\n check env cxt a' VU\n check env cxt t' a''\n check ((x, Just (eval env t')) :: env) ((x, a'') :: cxt) u a\n _ => do\n tty <- infer env cxt t\n when (not (conv env tty a)) $\n -- (quoteShow env a) (quoteShow env tty))\n report (\"type mismatch\\n\\nexpected type:\\n\\n \" ++ \"\" ++ \"\\n\\ninferred type:\\n\\n \" ++ \"\" ++ \"\\n\")\n\n-- printing\n\nShow Tm where\n show (Var x) = x\n show (Lam x t) = \"\\\\\" ++ x ++ \".\" ++ (show t)\n show (App t u) = (show t) ++ (show u)\n show U = \"U:\"\n show (Pi x t u) = \"(\" ++ x ++ \":\" ++ (show t) ++ \"->\" ++ (show u)\n show (Let x t u y) = \"let \" ++ x ++ \" : \" ++ (show t) ++ \" = \" ++ (show u) ++ \" in \" ++ (show y)\n show (SrcPos _ t) = show t\n", "meta": {"hexsha": "d5b691d42dd6692d0b4a90c68ae3ce65910e203c", "size": 5364, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "elab-zoo-typechecker/Zoo.idr", "max_stars_repo_name": "alexhumphreys/pl-playground", "max_stars_repo_head_hexsha": "da90cc3527e0ff3a7effd1f5dde5437b47ac1170", "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": "elab-zoo-typechecker/Zoo.idr", "max_issues_repo_name": "alexhumphreys/pl-playground", "max_issues_repo_head_hexsha": "da90cc3527e0ff3a7effd1f5dde5437b47ac1170", "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": "elab-zoo-typechecker/Zoo.idr", "max_forks_repo_name": "alexhumphreys/pl-playground", "max_forks_repo_head_hexsha": "da90cc3527e0ff3a7effd1f5dde5437b47ac1170", "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": 29.152173913, "max_line_length": 110, "alphanum_fraction": 0.4774422073, "num_tokens": 1787, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.709019146082187, "lm_q1q2_score": 0.582947835240729}}
{"text": "module Data.Filter\n\nimport Data.DList\nimport Data.List.Predicates.Interleaving\n\n%default total\n%access public export\n\ndata Filter : (holdsFor : type -> Type)\n -> (input : List type)\n -> Type where\n MkFilter : (kept : List type)\n -> (prfOrdering : Interleaving kept thrown input)\n -> (prfKept : DList type holdsFor kept)\n -> (prfThrown : DList type (Not . holdsFor) thrown)\n -> Filter holdsFor input\n\nfilter : (test : (value : type) -> Dec (holds value))\n -> (input : List type)\n -> Filter holds input\nfilter test [] = MkFilter [] Empty [] []\nfilter test (x :: xs) with (filter test xs)\n filter test (x :: xs) | (MkFilter kept prfOrdering prfKept prfThrown) with (test x)\n filter test (x :: xs) | (MkFilter kept prfOrdering prfKept prfThrown) | (Yes prf) =\n MkFilter (x::kept) (LeftAdd x prfOrdering) (prf :: prfKept) prfThrown\n filter test (x :: xs) | (MkFilter kept prfOrdering prfKept prfThrown) | (No contra) =\n MkFilter kept (RightAdd x prfOrdering) prfKept (contra :: prfThrown)\n", "meta": {"hexsha": "6df55b88816d32a5df58a9a854693f95dee09894", "size": 1077, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Data/Filter.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/Filter.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/Filter.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": 38.4642857143, "max_line_length": 89, "alphanum_fraction": 0.6332404828, "num_tokens": 324, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891218080991, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.5829478240071734}}
{"text": "module EqInterf\n\nimport Data.Nat\n\ninfix 6 =~=\n\n--------------------------------------------------\n--- Interfaces and general functions over them ---\n--------------------------------------------------\n\ninterface Equ ty where\n data (=~=) : ty -> ty -> Type\n\n 0 fromPropositional : {0 x, y : ty} -> (0 _ : x = y) -> x =~= y\n\n 0 reflexivity : {0 x : ty} -> x =~= x\n 0 symmetry : {0 x, y : ty} -> (0 _ : x =~= y) -> y =~= x\n 0 transitivity : {0 x, y, z : ty} -> (0 _ : x =~= y) -> (0 _ : y =~= z) -> x =~= z\n\ninterface Equ ty => Transp ty where\n 0 transport : (0 p : ty -> Type) -> {0 x, y : ty} -> (0 _ : x =~= y) -> p x -> p y\n\n0 congruence : Transp ty => Equ tu => (0 f : ty -> tu) -> {0 x, y : ty} -> (0 _ : x =~= y) -> f x =~= f y\ncongruence f xy = transport (\\i => f x =~= f i) xy reflexivity\n\ninterface Equ ty => EquProp ty where\n 0 equIsProp : (=~=) {ty} = Equal\n\n--interface Equ t => Equ u => Cong t u (0 f : t -> u) where\n-- 0 congruence : {0 x, y : t} -> (0 _ : x =~= y) -> f x =~= f y\n\ninterface Equ t => Equ u => Inj t u (0 f : t -> u) where\n 0 injectivity : {0 x, y : t} -> (0 _ : f x =~= f y) -> x =~= y\n\n---------------------------------------------\n--- Interfaces' implementations for `Nat` ---\n---------------------------------------------\n\nEqu Nat where\n (=~=) = Equal\n\n fromPropositional Refl = Refl\n\n reflexivity = Refl\n symmetry = sym\n transitivity = trans\n\nTransp Nat where\n transport _ Refl p = p\n\nEquProp Nat where\n equIsProp = Refl\n\nInj _ _ S where\n injectivity Refl = Refl\n\n0 injPlusL : {n : Nat} -> (n + x = n + y) -> x = y\ninjPlusL {n=Z} eq = eq\ninjPlusL {n=S k} eq = injPlusL $ injectivity {f=S} eq\n\nInj Nat _ (n+) where\n injectivity eq = injPlusL eq\n\nInj Nat _ (+n) where\n injectivity eq = injPlusL {n} rewrite plusCommutative n x in rewrite plusCommutative n y in eq\n\n----------------------------------------------------------\n--- Equality for functions as functional extensinality ---\n----------------------------------------------------------\n\n[WeakFunext] Equ b => Equ (a -> b) where\n f =~= g = (x : a) -> f x =~= g x\n\n fromPropositional Refl = \\_ => reflexivity\n\n reflexivity _ = reflexivity\n symmetry p x = symmetry $ p x\n transitivity p q x = transitivity (p x) (q x)\n\n[WeakFunextTransp] Equ b => Transp (a -> b) using WeakFunext where\n transport {x=f} {y=g} pr fg p = ?foo_transport -- impossible since implies actual functional extensionality\n\n[StrongFunext] Transp a => Equ b => Equ (a -> b) where\n f =~= g = (x, y : a) -> x =~= y -> f x =~= g y\n\n fromPropositional {y=f} Refl = \\_, _, xy => congruence f xy\n\n reflexivity {x=f} = \\_, _, xx => congruence f xx\n symmetry {x=f} {y=g} fg = \\x, y, xy => symmetry $ fg y x $ symmetry xy\n transitivity {x=f} {y=g} {z=h} fg gh = \\x, y, xy => fg x y xy `transitivity` gh y y reflexivity\n\n[StrongFunextTransp] Transp a => Equ b => Transp (a -> b) using StrongFunext where\n transport {x=f} {y=g} pr fg p = ?foo0 -- impossible since implies actual functional extensionality\n", "meta": {"hexsha": "2a7727de009bcd9462f8148929bb5ffd53c25e57", "size": 3002, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "EqInterf.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": "EqInterf.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": "EqInterf.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": 31.9361702128, "max_line_length": 109, "alphanum_fraction": 0.516655563, "num_tokens": 984, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8670357563664174, "lm_q2_score": 0.6723317057447908, "lm_q1q2_score": 0.5829356290195583}}
{"text": "import Data.List.Views\n\nrev : List a -> List a\nrev xs with (snocList xs)\n rev [] | Empty = []\n rev (ys ++ [x]) | (Snoc y) = x :: rev ys | y\n\n-- Show all the splits for all the recursive calls, to demonstrate they really\n-- are split in half\nshowDivisions : (xs : List a) -> List (List a)\nshowDivisions xs with (splitRec xs)\n showDivisions [] | SplitRecNil = []\n showDivisions [x] | SplitRecOne = [[x]]\n showDivisions (ys ++ zs) | (SplitRecPair ysrec zsrec) = \n (ys ++ zs) :: showDivisions ys | ysrec ++ showDivisions zs | zsrec\n\ntotal\nmergeSort : Ord a => List a -> List a\nmergeSort xs with (splitRec xs)\n mergeSort [] | SplitRecNil = []\n mergeSort [x] | SplitRecOne = [x]\n mergeSort (ys ++ zs) | SplitRecPair ysrec zsrec \n = merge (mergeSort ys | ysrec)\n (mergeSort zs | zsrec)\n\ntestList : Int -> Int -> List Int -> List Int\ntestList 0 seed acc = acc\n-- Need to explicitly mod since different back ends overflow differently\ntestList x seed acc = let seed' = (seed * 12345 + 768) `mod` 65536 in\n testList (x - 1) seed' \n ((seed' `mod` 100) :: acc)\n\nmyhead : List a -> a\nmyhead (x :: xs) = x\n\nmain : IO ()\nmain = do let list = testList 100 12345 []\n putStrLn \"Sorting list\"\n let list' = mergeSort list\n printLn list'\n printLn (rev list')\n\n\n", "meta": {"hexsha": "7d517a81a703f4b22a13c0b447e27ca20d1931b5", "size": 1359, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "test/idris-dev/views001/views001.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/views001/views001.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/views001/views001.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.8863636364, "max_line_length": 78, "alphanum_fraction": 0.5967623252, "num_tokens": 403, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959545, "lm_q2_score": 0.727975460709318, "lm_q1q2_score": 0.5828841291120687}}
{"text": "import Control.Monad.State\n\nincrease : Nat -> State Nat ()\nincrease inc = do current <- get\n put (current + inc)\n\n", "meta": {"hexsha": "b99c5e019a34c981a37fe6544e78433905e18a07", "size": 131, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "type_driven_book/chp12/State.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/chp12/State.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/chp12/State.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": 18.7142857143, "max_line_length": 37, "alphanum_fraction": 0.5954198473, "num_tokens": 27, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.766293653760418, "lm_q2_score": 0.7606506472514406, "lm_q1q2_score": 0.5828817637175333}}
{"text": "module Russell\n\n-- Based on https://github.com/agda/agda/blob/master/test/Succeed/Russell.agda\n\ndata U : Type where\n Set : (I : Type) -> (I -> U) -> U\n\nRegular : U -> Type\nRegular (Set I f) = (i : I) -> (f i = Set I f) -> Void\n\nR : U\nR = Set (DPair U Regular) fst\n\nnotRegular : Regular R -> Void\nnotRegular reg = reg (R ** reg) Refl\n\ntransport : {A : Type} -> (C : A -> Type) -> {x : A} -> {y : A} -> x = y -> C x -> C y\ntransport _ Refl ca = ca\n\nregular : Regular R\nregular (x ** pf) eq = transport Regular eq pf (x ** pf) eq\n\nabsurd : Void\nabsurd = notRegular regular\n", "meta": {"hexsha": "5ea5f331224a4bfb97b2231797987b7e020ff23a", "size": 571, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Russell.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/Russell.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/Russell.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": 22.84, "max_line_length": 86, "alphanum_fraction": 0.5901926445, "num_tokens": 196, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.894789457685656, "lm_q2_score": 0.6513548714339144, "lm_q1q2_score": 0.5828254721712623}}
{"text": "> module SimpleProb.MonadicProperties\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 SimpleProb.MonadicOperations\n> import NonNegRational.NonNegRational\n> import NonNegRational.BasicOperations\n> import NonNegRational.BasicProperties\n\n> import Nat.Positive\n> import Nat.Coprime\n> import Fraction.Normal\n> import Num.Refinements\n> import Num.Properties\n> import Fun.Operations\n> import List.Operations\n> import List.Properties\n> import Unique.Predicates\n> import Finite.Predicates\n> import Sigma.Sigma\n\n> %default total\n> %access public export\n> -- %access export\n> %auto_implicits off\n\n\n* Properties of |normalize|, |support| and |ret|:\n\n> |||\n> normalizeRetLemma : {A : Type} -> (a : A) -> normalize (ret a) = ret a\n> normalizeRetLemma a = ( normalize (ret a) )\n> ={ Refl }=\n> ( normalize (MkSimpleProb ((a, 1) :: Nil) (sumMapSndSingletonLemma a 1)) )\n> ={ Refl }=\n> ( MkSimpleProb ((a, 1) :: Nil) (sumMapSndSingletonLemma a 1) ) \n> ={ Refl }= \n> ( ret a )\n> QED\n> {-\n> normalizeRetLemma a = s9 where\n> s1 : normalize (ret a) = normalize (MkSimpleProb ((a, 1) :: Nil) (sumMapSndSingletonLemma a 1))\n> s1 = Refl\n> s2 : normalize (MkSimpleProb ((a, 1) :: Nil) (sumMapSndSingletonLemma a 1))\n> =\n> MkSimpleProb (discardBySndZero ((a, 1) :: Nil)) \n> (trans (discardBySndZeroLemma ((a, 1) :: Nil)) (sumMapSndSingletonLemma a 1))\n> s2 = Refl \n> s3 : discardBySndZero ((a, 1) :: Nil) = (a, 1) :: Nil\n> s3 = discardBySndZeroLemma1 a 1 ?oneNotZero\n> s4 : discardBySndZeroLemma ((a, 1) :: Nil) = Refl {} {} {}\n> s4 = ?lika\n> s5 : MkSimpleProb (discardBySndZero ((a, 1) :: Nil)) \n> (trans (discardBySndZeroLemma ((a, 1) :: Nil)) (sumMapSndSingletonLemma a 1))\n> =\n> MkSimpleProb ((a, 1) :: Nil) (trans Refl (sumMapSndSingletonLemma a 1))\n> s5 = ?leka\n> s6 : MkSimpleProb ((a, 1) :: Nil) (trans Refl (sumMapSndSingletonLemma a 1))\n> = \n> MkSimpleProb ((a, 1) :: Nil) (sumMapSndSingletonLemma a 1)\n> s6 = Refl\n> s7 : MkSimpleProb ((a, 1) :: Nil) (sumMapSndSingletonLemma a 1) = ret a\n> s7 = Refl\n> s9 : normalize (ret a) = ret a\n> s9 = trans s1 (trans s2 (trans s5 (trans s6 s7)))\n> -}\n\n> |||\n> supportRetLemma : {A : Type} -> \n> (a : A) -> support (SimpleProb.MonadicOperations.ret a) = List.Operations.ret a\n> supportRetLemma a = ( support (SimpleProb.MonadicOperations.ret a) )\n> ={ Refl }=\n> ( map fst (toList (normalize (SimpleProb.MonadicOperations.ret a))) )\n> ={ cong {f = \\ X => map Prelude.Basics.fst (toList X)} (normalizeRetLemma a) }=\n> ( map fst (toList (SimpleProb.MonadicOperations.ret a)) )\n> ={ Refl }=\n> ( map fst (toList (MkSimpleProb ((a, 1) :: Nil) (sumMapSndSingletonLemma a 1))) )\n> ={ Refl }=\n> ( map fst ((a, 1) :: Nil) ) \n> ={ Refl }=\n> ( a :: Nil ) \n> ={ Refl }=\n> ( List.Operations.ret a )\n> QED \n\n\n* |SimpleProb| is a container monad:\n\n> |||\n> elemNonEmptySpec0 : {A : Type} ->\n> (a : A) -> (sp : SimpleProb A) ->\n> a `Elem` sp -> SimpleProb.MonadicOperations.NonEmpty sp\n> elemNonEmptySpec0 {A} a sp aesp = List.Properties.elemNonEmptySpec0 a (support sp) aesp\n\n> |||\n> elemNonEmptySpec1 : {A : Type} ->\n> (sp : SimpleProb A) ->\n> SimpleProb.MonadicOperations.NonEmpty sp -> Sigma A (\\ a => a `Elem` sp)\n> elemNonEmptySpec1 {A} sp nesp = List.Properties.elemNonEmptySpec1 (support sp) nesp\n\n> |||\n> containerMonadSpec1 : {A : Type} -> {a : A} -> a `SimpleProb.MonadicOperations.Elem` (ret a)\n> containerMonadSpec1 {A} {a} = s3 where\n> s1 : a `Data.List.Elem` (List.Operations.ret a)\n> s1 = List.Properties.containerMonadSpec1\n> s2 : a `Data.List.Elem` (support (SimpleProb.MonadicOperations.ret a))\n> s2 = replace {P = \\ X => a `Data.List.Elem` X} (sym (supportRetLemma a)) s1\n> s3 : a `SimpleProb.MonadicOperations.Elem` (ret a)\n> s3 = s2\n\n> |||\n> containerMonadSpec3 : {A : Type} -> {P : A -> Type} ->\n> (a : A) -> (sp : SimpleProb A) ->\n> All P sp -> a `Elem` sp -> P a\n> containerMonadSpec3 {A} {P} a sp allp elemp = List.Properties.containerMonadSpec3 a (support sp) allp elemp\n\n\n\n* Specific container monad properties\n\n> |||\n> uniqueAllLemma : {A : Type} -> {P : A -> Type} -> \n> Unique1 P -> (sp : SimpleProb A) -> Unique (All P sp)\n> uniqueAllLemma u1P sp = List.Properties.uniqueAllLemma u1P (support sp)\n\n> |||\n> finiteAll : {A : Type} -> {P : A -> Type} -> \n> Finite1 P -> (sp : SimpleProb A) -> Finite (All P sp)\n> finiteAll f1P sp = List.Properties.finiteAll f1P (support sp)\n\n> ||| All is decidable\n> decidableAll : {A : Type} -> {P : A -> Type} -> \n> (dec : (a : A) -> Dec (P a)) -> (sp : SimpleProb A) -> Dec (All P sp)\n> decidableAll dec sp = List.Properties.decidableAll dec (support sp)\n\n> ||| NotEmpty is finite\n> finiteNonEmpty : {A : Type} -> (sp : SimpleProb A) -> Finite (SimpleProb.MonadicOperations.NonEmpty sp)\n> finiteNonEmpty sp = List.Properties.finiteNonEmpty (support sp)\n\n> ||| NotEmpty is decidable\n> decidableNonEmpty : {A : Type} -> (sp : SimpleProb A) -> Dec (SimpleProb.MonadicOperations.NonEmpty sp)\n> decidableNonEmpty sp = List.Properties.decidableNonEmpty (support sp)\n\n* |SimpleProb|s are never empty\n\n> |||\n> nonEmptyLemma1 : {A : Type} -> (sp : SimpleProb A) -> List.Operations.NonEmpty (toList sp)\n> nonEmptyLemma1 {A} (MkSimpleProb Nil s1p) = void s9 where\n> s1 : sumMapSnd {A = A} {B = NonNegRational} Nil = 0\n> s1 = sumMapSndNilLemma {A = A} {B = NonNegRational}\n> s2 : sumMapSnd {A = A} {B = NonNegRational} Nil = 1\n> s2 = s1p\n> s3 : (=) {A = NonNegRational} {B = NonNegRational} 1 0\n> s3 = trans (sym s2) s1\n> s9 : Void\n> s9 = not1Eq0 s3\n> nonEmptyLemma1 (MkSimpleProb (ap :: aps) s1p) = () \n\n> |||\n> nonEmptyLemma : {A : Type} -> (sp : SimpleProb A) -> NonEmpty sp\n> nonEmptyLemma {A} sp = s4 where\n> s1 : List.Operations.NonEmpty (toList (normalize sp))\n> s1 = nonEmptyLemma1 (normalize sp)\n> s2 : List.Operations.NonEmpty (map fst (toList (normalize sp)))\n> s2 = mapPreservesNonEmpty fst (toList (normalize sp)) s1\n> s3 : List.Operations.NonEmpty (support sp) \n> s3 = s2\n> s4 : NonEmpty sp\n> s4 = s3\n\n\n> |||\n> toListFmapLemma : {A, B : Type} -> \n> (f : A -> B) -> (sp : SimpleProb A) ->\n> toList (fmap f sp) = fmap (cross f id) (toList sp)\n> toListFmapLemma f (MkSimpleProb aps s1p) = \n> ( toList (fmap f (MkSimpleProb aps s1p)) )\n> ={ Refl }=\n> ( toList (MkSimpleProb \n> (fmap (cross f id) aps) \n> (trans Refl (trans (cong (mapSndMapCrossAnyIdLemma f aps)) s1p))) )\n> ={ Refl }= \n> ( fmap (cross f id) aps )\n> ={ Refl }=\n> ( fmap (cross f id) (toList (MkSimpleProb aps s1p)) )\n> QED\n\n\n> {-\n\n> ---}\n", "meta": {"hexsha": "34bb3441767b1ef2495d0af57b32ca401ed22211", "size": 7367, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "SimpleProb/MonadicProperties.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/MonadicProperties.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/MonadicProperties.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": 37.3959390863, "max_line_length": 109, "alphanum_fraction": 0.5756753088, "num_tokens": 2378, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.7549149868676283, "lm_q1q2_score": 0.5826762240350494}}
{"text": "-- examples in \"Type-Driven Development with Idris\"\n-- chapter 10\n\nimport Data.Vect\nimport Data.List.Views\nimport Data.Vect.Views\nimport Data.Nat.Views\n\n-- check that all functions are total\n%default total\n\n--\n-- section 10.1\n--\n\n-- first a function using a view, without `with`\n-- we have:\n-- - a view V : Tin -> Type\n-- - a covering function covV : (x : Tin) -> V x\n-- - a helper fHelp : (x : Tin) -> (form : V x) -> Tout\n-- - the function f : Tin -> Tout, with f in = fHelp in (covV in)\n\n||| A view\ndata ListLast : List a -> Type where\n Empty : ListLast []\n NonEmpty : (xs : List a) -> (x : a) -> ListLast (xs ++ [x])\n\n||| The covering function of the ListLast view\nlistLast : (xs : List a) -> ListLast xs\nlistLast [] = Empty\nlistLast (x :: xs) = case listLast xs of\n Empty => NonEmpty [] x\n (NonEmpty ys y) => NonEmpty (x :: ys) y\n\n||| The helper of the function, defined in terms of the view\ndescribeHelperInt : (input : List Int) -> (form : ListLast input) -> String\ndescribeHelperInt [] Empty = \"Empty\"\ndescribeHelperInt (xs ++ [x]) (NonEmpty xs x)\n = \"Non-empty, initial portion = \" ++ show xs\n\n||| generalized version of the helper (from Int to a)\ndescribeHelper : Show a => (input : List a) -> (form : ListLast input) -> String\ndescribeHelper [] Empty = \"Empty\"\ndescribeHelper (xs ++ [x]) (NonEmpty xs x)\n = \"Non-empty, initial portion = \" ++ show xs\n\n||| The function using the view\ndescribeListEndInt : List Int -> String\ndescribeListEndInt xs = describeHelperInt xs (listLast xs)\n\n||| generalized version of the helper (from Int to a)\ndescribeListEnd : Show a => List a -> String\ndescribeListEnd xs = describeHelper xs (listLast xs)\n\n-- ok:\n-- > describeListEndInt [1,2,3]\n-- \"Non-empty, initial portion = [1, 2]\" : String\n-- > describeListEndInt [1]\n-- \"Non-empty, initial portion = []\" : String\n-- > describeListEndInt []\n-- \"Empty\" : String\n-- > describeListEnd [1,2,3]\n-- \"Non-empty, initial portion = [1, 2]\" : String\n-- > describeListEnd [1]\n-- \"Non-empty, initial portion = []\" : String\n-- > describeListEnd $ the (List Int) []\n-- \"Empty\" : String\n-- if a is not known:\n-- > describeListEnd []\n-- Can't find implementation for Show a\n\n-- a version with `with`\n-- we have:\n-- - a view V : Tin -> Type\n-- - a covering function covV : (x : Tin) -> V x\n-- - the function f : Tin -> Tout, using the \"with covV\" construct\n\ndescribeListEnd2 : List Int -> String\ndescribeListEnd2 xs with (listLast xs)\n describeListEnd2 [] | Empty = \"Empty\"\n describeListEnd2 (ys ++ [x]) | (NonEmpty ys x)\n = \"Non-empty, initial portion = \" ++ show ys\n\npartial\nmyReversePartial : List Int -> List Int\nmyReversePartial xs with (listLast xs)\n myReversePartial [] | Empty = []\n myReversePartial (ys ++ [x]) | (NonEmpty ys x) = x :: myReversePartial ys\n\ndata SplitList : List a -> Type where\n SplitNil : SplitList []\n SplitOne : SplitList [x]\n SplitPair : (lefts : List a) -> (rights : List a) -> SplitList (lefts ++ pairs)\n\nsplitList : (input : List a) -> SplitList input\nsplitList input = splitListHelper input input\n where\n splitListHelper : List a -> (input : List a) -> SplitList input\n splitListHelper _ [] = SplitNil\n splitListHelper _ [x] = SplitOne\n splitListHelper (_ :: _ :: counter) (item :: items)\n = case splitListHelper counter items of\n SplitNil => SplitOne\n SplitOne {x} => SplitPair [item] [x]\n SplitPair lefts rights => SplitPair (item :: lefts) rights\n splitListHelper _ items = SplitPair [] items\n\npartial\nmergeSort : Ord a => List a -> List a\nmergeSort xs with (splitList xs)\n mergeSort [] | SplitNil = []\n mergeSort [x] | SplitOne = [x]\n mergeSort (lefts ++ pairs) | (SplitPair lefts rights)\n = merge (mergeSort lefts) (mergeSort rights)\n\n--\n-- section 10.2\n--\n\ndata SnocList0 ty = SnocEmpty0 | Snoc0 (SnocList0 ty) ty\n\nreverseSnoc0 : SnocList0 ty -> List ty\nreverseSnoc0 SnocEmpty0 = []\nreverseSnoc0 (Snoc0 xs x) = x :: reverseSnoc0 xs\n\ndata MySnocList : List a -> Type where\n MySnocEmpty : MySnocList []\n MySnoc : (rec : MySnocList xs) -> MySnocList (xs ++ [x])\n\nsnocListHelp : (snoc : MySnocList input) -> (rest : List a) ->\n MySnocList (input ++ rest)\nsnocListHelp {input} snoc [] = rewrite appendNilRightNeutral input in snoc\nsnocListHelp {input} snoc (x :: xs) = rewrite appendAssociative input [x] xs in\n (snocListHelp (MySnoc snoc {x}) xs)\n\nmySnocList : (xs : List a) -> MySnocList xs\nmySnocList xs = snocListHelp MySnocEmpty xs\n\nmyReverseHelper : (input : List a) -> MySnocList input -> List a\nmyReverseHelper [] MySnocEmpty = []\nmyReverseHelper (xs ++ [x]) (MySnoc rec) = myReverseHelper xs rec\n\nmyReverse : List a -> List a\nmyReverse input with (mySnocList input)\n myReverse [] | MySnocEmpty = []\n myReverse (xs ++ [x]) | (MySnoc rec) = x :: myReverse xs | rec\n\nisSuffix : Eq a => List a -> List a -> Bool\nisSuffix input1 input2 with (mySnocList input1)\n isSuffix [] input2 | MySnocEmpty = True\n isSuffix (xs ++ [x]) input2 | (MySnoc xsrec) with (mySnocList input2)\n isSuffix (xs ++ [x]) [] | (MySnoc xsrec) | MySnocEmpty = False\n isSuffix (xs ++ [x]) (ys ++ [y]) | (MySnoc xsrec) | (MySnoc ysrec)\n = if x == y then isSuffix xs ys | xsrec | ysrec\n else False\n\nmergeSort2 : Ord a => List a -> List a\nmergeSort2 input with (splitRec input)\n mergeSort2 [] | SplitRecNil = []\n mergeSort2 [x] | SplitRecOne = [x]\n mergeSort2 (lefts ++ rights) | (SplitRecPair lrec rrec)\n = merge (mergeSort lefts | lrec)\n (mergeSort rights | rrec)\n", "meta": {"hexsha": "2d18d6fafe02a7d18a47ef31fe3a557b0ba7f89e", "size": 5570, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "chapter10/examples.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": "chapter10/examples.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": "chapter10/examples.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": 33.9634146341, "max_line_length": 81, "alphanum_fraction": 0.6436265709, "num_tokens": 1698, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.8175744761936437, "lm_q1q2_score": 0.5823028549574116}}
{"text": "import Data.Vect\n\n-- Exercise 1\nMatrix : Nat -> Nat -> Type\nMatrix rows cols = Vect rows (Vect cols Double)\n\ntestMatrix : Matrix 3 3\ntestMatrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]\n\n--Exercise 2\ndata Format = Number Format\n | Str Format\n | Lit String Format\n | Chr Format\n | Dbl Format\n | End\n\nPrintfType : Format -> Type\nPrintfType (Number fmt) = (i : Int) -> PrintfType fmt\nPrintfType (Str fmt) = (str : String) -> PrintfType fmt\nPrintfType (Lit str fmt) = PrintfType fmt\nPrintfType (Chr fmt) = (chr : Char) -> PrintfType fmt\nPrintfType (Dbl fmt) = (dbl : Double) -> PrintfType fmt\nPrintfType End = String\n\nprintfFmt : (fmt : Format) -> (acc : String) -> PrintfType fmt\nprintfFmt (Number fmt) acc = \\i => printfFmt fmt (acc ++ show i)\nprintfFmt (Str fmt) acc = \\str => printfFmt fmt (acc ++ str)\nprintfFmt (Lit lit fmt) acc = printfFmt fmt (acc ++ lit)\nprintfFmt (Chr fmt) acc = \\c => printfFmt fmt (acc ++ show c)\nprintfFmt (Dbl fmt) acc = \\d => printfFmt fmt (acc ++ show d)\nprintfFmt End acc = acc\n\ntoFormat : (xs : List Char) -> Format\ntoFormat [] = End\ntoFormat ('%' :: 'd' :: chars) = Number (toFormat chars)\ntoFormat ('%' :: 's' :: chars) = Str (toFormat chars)\ntoFormat ('%' :: 'c' :: chars) = Chr (toFormat chars)\ntoFormat ('%' :: 'f' :: chars) = Dbl (toFormat chars)\ntoFormat ('%' :: chars) = Lit \"%\" (toFormat chars)\ntoFormat (c :: chars) = case toFormat chars of\n (Lit lit chars') => Lit (strCons c lit) chars'\n fmt => Lit (strCons c \"\") fmt\n\n\nprintf : (fmt : String) -> PrintfType (toFormat (unpack fmt))\nprintf fmt = printfFmt _ \"\"\n\n-- Exercise 3\nTupleVect : Nat -> Type -> Type\nTupleVect Z ty = ()\nTupleVect (S k) ty = (ty, TupleVect k ty)\n\ntest : TupleVect 4 Nat\ntest = (1,2,3,4,())\n", "meta": {"hexsha": "6f3df268ef94e828b91dc81b7e3f1637f686ad72", "size": 1834, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "TypeDrivenDevelopment/Chapter06/Exercises/ex_6_2.idr", "max_stars_repo_name": "lambdaxymox/type-driven-development-with-idris", "max_stars_repo_head_hexsha": "e5e55715cd7418f3e6fab8e5658d7518da3fdce7", "max_stars_repo_licenses": ["Apache-2.0", "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": "TypeDrivenDevelopment/Chapter06/Exercises/ex_6_2.idr", "max_issues_repo_name": "lambdaxymox/type-driven-development-with-idris", "max_issues_repo_head_hexsha": "e5e55715cd7418f3e6fab8e5658d7518da3fdce7", "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": "TypeDrivenDevelopment/Chapter06/Exercises/ex_6_2.idr", "max_forks_repo_name": "lambdaxymox/type-driven-development-with-idris", "max_forks_repo_head_hexsha": "e5e55715cd7418f3e6fab8e5658d7518da3fdce7", "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": 32.75, "max_line_length": 75, "alphanum_fraction": 0.5910577972, "num_tokens": 554, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744806385543, "lm_q2_score": 0.7122321781307375, "lm_q1q2_score": 0.582302853129304}}
{"text": "module ViluonsMachine\n\nimport Data.Fin\nimport Data.Vect\n\ndata Instr : (nr : Nat) -> (ni : Nat) -> Type where\n\tIJmp : Fin (S ni) -> Instr nr ni\n\tIJIZ : Fin nr -> Fin (S ni) -> Instr nr ni\n\tIIncr : Fin nr -> Instr nr ni\n\tIDecr : Fin nr -> Instr nr ni\n\ndata Prog : (nr : Nat) -> Type where\n\tMkProg : {ni : Nat} -> Vect ni (Instr nr ni) -> Prog nr\n\nraiseFin : Fin n -> Fin (S n)\nraiseFin FZ = FZ\nraiseFin (FS f) = FS $ raiseFin f\n\nraiseFin' : Fin n -> Fin (m + n)\nraiseFin' {m=Z} f = f\nraiseFin' {m=S m} f = raiseFin $ raiseFin' f\n\nincrFin : Fin n -> Fin (m + n)\nincrFin {m=Z} f = f\nincrFin {m=S m} f = FS $ incrFin f\n\nreduceFin : Fin (S n) -> Maybe (Fin n)\nreduceFin {n=Z} f = Nothing\nreduceFin {n=S n} FZ = Just FZ\nreduceFin {n=S n} (FS f) = map FS $ reduceFin f\n\nmapJumps : (Fin (S n) -> Fin (S m)) -> Instr nr n -> Instr nr m\nmapJumps f (IJmp to) = IJmp $ f to\nmapJumps f (IJIZ r to) = IJIZ r $ f to\nmapJumps f (IIncr r) = IIncr r\nmapJumps f (IDecr r) = IDecr r\n\nSemigroup (Prog nr) where\n\t(MkProg {ni=na} a) <+> (MkProg {ni=nb} b) =\n\t\tMkProg $\n\t\tmap (mapJumps $ replace {P=Fin} (plusCommutative nb (S na)) . raiseFin') a\n\t\t++\n\t\tmap (mapJumps $ replace {P=Fin} (sym $ plusSuccRightSucc na nb) . incrFin) b\n\nMonoid (Prog nr) where\n\tneutral = MkProg []\n\nMemState : Nat -> Type\nMemState nr = Vect nr Nat\nExecState : Nat -> Type\nExecState ni = Fin ni\n\ntotal\ntick : Instr nr ni -> (ExecState ni, MemState nr) -> (ExecState (S ni), MemState nr)\ntick (IJmp to) (_, ms) = (to, ms)\ntick (IJIZ r to) (es, ms) =\n\tif index r ms == 0\n\tthen (to, ms)\n\telse (FS es, ms)\ntick (IIncr r) (es, ms) = (FS es, updateAt r S ms)\ntick (IDecr r) (es, ms) = (FS es, updateAt r (\\a => minus a 1) ms)\n\ntotal\ntick' : Vect ni (Instr nr ni) -> (ExecState ni, MemState nr) -> MemState nr\ntick' prog (es, ms) = let\n\t\ts' = tick (index es prog) (es, ms)\n\tin maybe (snd s') (\\es'' => assert_total $ tick' prog (es'', snd s')) $ reduceFin $ fst s'\n\ntotal\nexec : Prog nr -> MemState nr -> MemState nr\nexec (MkProg {ni=Z} prog) ms = ms\nexec (MkProg {ni=S ni} prog) ms = tick' prog (0, ms)\n\ntotal\nreduceFinLast : {n : Nat} -> reduceFin (last {n}) = Nothing\nreduceFinLast {n=Z} = Refl\nreduceFinLast {n=S n} = replace {P = \\l => map FS l = Nothing} (sym $ reduceFinLast {n}) Refl\n\n-- execEndIf :\n-- \t(prog : Vect ni (Instr nr ni)) ->\n-- \t(es : ExecState ni) ->\n-- \t(ms : MemState nr) ->\n-- \tfst (tick (index es prog) (es, ms)) = last ->\n-- \ttick' prog (es, ms) = snd (tick (index es prog) (es, ms))\n-- execEndIf prog es ms prf = ?t\n\n-- execEndIff :\n-- \t(prog : Vect ni (Instr nr ni)) ->\n-- \t\n\ntoZero : Fin nr -> Prog nr\ntoZero reg = MkProg [\n\tIJIZ reg 3,\n\tIDecr reg,\n\tIJmp 0\n]\n\ntoZeroZero : index r (exec (toZero r) ms) = 0\n-- toZeroZero = ?t\n", "meta": {"hexsha": "4f28eb7dd4c1699f0459a83c6f2ccf051418e90a", "size": 2700, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris/test.idr", "max_stars_repo_name": "CoderPuppy/viluons-machine", "max_stars_repo_head_hexsha": "ec8fe27234baa2722767495fe7d02ee990c3c127", "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/test.idr", "max_issues_repo_name": "CoderPuppy/viluons-machine", "max_issues_repo_head_hexsha": "ec8fe27234baa2722767495fe7d02ee990c3c127", "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/test.idr", "max_forks_repo_name": "CoderPuppy/viluons-machine", "max_forks_repo_head_hexsha": "ec8fe27234baa2722767495fe7d02ee990c3c127", "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": 27.0, "max_line_length": 93, "alphanum_fraction": 0.6025925926, "num_tokens": 1053, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9184802484881361, "lm_q2_score": 0.6334102775181399, "lm_q1q2_score": 0.5817748290898005}}
{"text": "module Data.Nat\n\nimport public Control.Relation\nimport public Control.Order\n\n%default total\n\nexport\nUninhabited (Z = S n) where\n uninhabited Refl impossible\n\nexport\nUninhabited (S n = Z) where\n uninhabited Refl impossible\n\nexport\nUninhabited (a = b) => Uninhabited (S a = S b) where\n uninhabited Refl @{ab} = uninhabited @{ab} Refl\n\npublic export\nisZero : Nat -> Bool\nisZero Z = True\nisZero (S n) = False\n\npublic export\nisSucc : Nat -> Bool\nisSucc Z = False\nisSucc (S n) = True\n\npublic export\ndata IsSucc : (n : Nat) -> Type where\n ItIsSucc : IsSucc (S n)\n\nexport\nUninhabited (IsSucc Z) where\n uninhabited ItIsSucc impossible\n\npublic export\nisItSucc : (n : Nat) -> Dec (IsSucc n)\nisItSucc Z = No absurd\nisItSucc (S n) = Yes ItIsSucc\n\npublic export\npower : Nat -> Nat -> Nat\npower base Z = S Z\npower base (S exp) = base * (power base exp)\n\npublic export\nhyper : Nat -> Nat -> Nat -> Nat\nhyper Z a b = S b\nhyper (S Z) a Z = a\nhyper (S(S Z)) a Z = Z\nhyper n a Z = S Z\nhyper (S pn) a (S pb) = hyper pn a (hyper (S pn) a pb)\n\npublic export\npred : Nat -> Nat\npred Z = Z\npred (S n) = n\n\n-- Comparisons\n\npublic export\ndata NotBothZero : (n, m : Nat) -> Type where\n LeftIsNotZero : NotBothZero (S n) m\n RightIsNotZero : NotBothZero n (S m)\n\nexport\nUninhabited (NotBothZero 0 0) where\n uninhabited LeftIsNotZero impossible\n uninhabited RightIsNotZero impossible\n\npublic export\ndata LTE : (n, m : Nat) -> Type where\n LTEZero : LTE Z right\n LTESucc : LTE left right -> LTE (S left) (S right)\n\nexport\nUninhabited (LTE (S n) Z) where\n uninhabited LTEZero impossible\n\nexport\nUninhabited (LTE m n) => Uninhabited (LTE (S m) (S n)) where\n uninhabited (LTESucc lte) = uninhabited lte\n\npublic export\nReflexive Nat LTE where\n reflexive {x = Z} = LTEZero\n reflexive {x = S k} = LTESucc $ reflexive {x = k}\n\npublic export\nTransitive Nat LTE where\n transitive LTEZero _ = LTEZero\n transitive (LTESucc xy) (LTESucc yz) =\n LTESucc $ transitive {rel = LTE} xy yz\n\npublic export\nAntisymmetric Nat LTE where\n antisymmetric LTEZero LTEZero = Refl\n antisymmetric (LTESucc xy) (LTESucc yx) =\n cong S $ antisymmetric xy yx\n\npublic export\nConnex Nat LTE where\n connex {x = Z} _ = Left LTEZero\n connex {y = Z} _ = Right LTEZero\n connex {x = S _} {y = S _} prf =\n case connex {rel = LTE} $ prf . (cong S) of\n Left jk => Left $ LTESucc jk\n Right kj => Right $ LTESucc kj\n\npublic export\nPreorder Nat LTE where\n\npublic export\nPartialOrder Nat LTE where\n\npublic export\nLinearOrder Nat LTE where\n\npublic export\nGTE : Nat -> Nat -> Type\nGTE left right = LTE right left\n\npublic export\nLT : Nat -> Nat -> Type\nLT left right = LTE (S left) right\n\nnamespace LT\n\n ||| LT is defined in terms of LTE which makes it annoying to use.\n ||| This convenient view of allows us to avoid having to constantly\n ||| perform nested matches to obtain another LT subproof instead of\n ||| an LTE one.\n public export\n data View : LT m n -> Type where\n LTZero : View (LTESucc LTEZero)\n LTSucc : (lt : m `LT` n) -> View (LTESucc lt)\n\n ||| Deconstruct an LT proof into either a base case or a further *LT*\n export\n view : (lt : LT m n) -> View lt\n view (LTESucc LTEZero) = LTZero\n view (LTESucc lt@(LTESucc _)) = LTSucc lt\n\n ||| A convenient alias for trivial LT proofs\n export\n ltZero : Z `LT` S m\n ltZero = LTESucc LTEZero\n\npublic export\nGT : Nat -> Nat -> Type\nGT left right = LT right left\n\nexport\nsuccNotLTEzero : Not (LTE (S m) Z)\nsuccNotLTEzero LTEZero impossible\n\nexport\nfromLteSucc : LTE (S m) (S n) -> LTE m n\nfromLteSucc (LTESucc x) = x\n\nexport\nsuccNotLTEpred : {x : Nat} -> Not $ LTE (S x) x\nsuccNotLTEpred {x = 0} prf = succNotLTEzero prf\nsuccNotLTEpred {x = S _} prf = succNotLTEpred $ fromLteSucc prf\n\npublic export\nisLTE : (m, n : Nat) -> Dec (LTE m n)\nisLTE Z n = Yes LTEZero\nisLTE (S k) Z = No succNotLTEzero\nisLTE (S k) (S j)\n = case isLTE k j of\n No contra => No (contra . fromLteSucc)\n Yes prf => Yes (LTESucc prf)\n\npublic export\nisGTE : (m, n : Nat) -> Dec (GTE m n)\nisGTE m n = isLTE n m\n\npublic export\nisLT : (m, n : Nat) -> Dec (LT m n)\nisLT m n = isLTE (S m) n\n\npublic export\nisGT : (m, n : Nat) -> Dec (GT m n)\nisGT m n = isLT n m\n\nexport\nlteSuccRight : LTE n m -> LTE n (S m)\nlteSuccRight LTEZero = LTEZero\nlteSuccRight (LTESucc x) = LTESucc (lteSuccRight x)\n\nexport\nlteSuccLeft : LTE (S n) m -> LTE n m\nlteSuccLeft (LTESucc x) = lteSuccRight x\n\nexport\nlteAddRight : (n : Nat) -> LTE n (n + m)\nlteAddRight Z = LTEZero\nlteAddRight (S k) {m} = LTESucc (lteAddRight {m} k)\n\nexport\nnotLTEImpliesGT : {a, b : Nat} -> Not (a `LTE` b) -> a `GT` b\nnotLTEImpliesGT {a = 0 } not_z_lte_b = absurd $ not_z_lte_b LTEZero\nnotLTEImpliesGT {a = S a} {b = 0 } notLTE = LTESucc LTEZero\nnotLTEImpliesGT {a = S a} {b = S k} notLTE = LTESucc (notLTEImpliesGT (notLTE . LTESucc))\n\nexport\nLTEImpliesNotGT : a `LTE` b -> Not (a `GT` b)\nLTEImpliesNotGT LTEZero q = absurd q\nLTEImpliesNotGT (LTESucc p) (LTESucc q) = LTEImpliesNotGT p q\n\nexport\nnotLTImpliesGTE : {a, b : _} -> Not (LT a b) -> GTE a b\nnotLTImpliesGTE notLT = fromLteSucc $ notLTEImpliesGT notLT\n\nexport\nLTImpliesNotGTE : a `LT` b -> Not (a `GTE` b)\nLTImpliesNotGTE p q = LTEImpliesNotGT q p\n\npublic export\nlte : Nat -> Nat -> Bool\nlte Z right = True\nlte left Z = False\nlte (S left) (S right) = lte left right\n\npublic export\ngte : Nat -> Nat -> Bool\ngte left right = lte right left\n\npublic export\nlt : Nat -> Nat -> Bool\nlt left right = lte (S left) right\n\npublic export\ngt : Nat -> Nat -> Bool\ngt left right = lt right left\n\nexport\nlteReflectsLTE : (k : Nat) -> (n : Nat) -> lte k n === True -> k `LTE` n\nlteReflectsLTE (S k) 0 _ impossible\nlteReflectsLTE 0 0 _ = LTEZero\nlteReflectsLTE 0 (S k) _ = LTEZero\nlteReflectsLTE (S k) (S j) prf = LTESucc (lteReflectsLTE k j prf)\n\nexport\ngteReflectsGTE : (k : Nat) -> (n : Nat) -> gte k n === True -> k `GTE` n\ngteReflectsGTE k n prf = lteReflectsLTE n k prf\n\nexport\nltReflectsLT : (k : Nat) -> (n : Nat) -> lt k n === True -> k `LT` n\nltReflectsLT k n prf = lteReflectsLTE (S k) n prf\n\nexport\ngtReflectsGT : (k : Nat) -> (n : Nat) -> gt k n === True -> k `GT` n\ngtReflectsGT k n prf = ltReflectsLT n k prf\n\npublic export\nminimum : Nat -> Nat -> Nat\nminimum Z m = Z\nminimum (S n) Z = Z\nminimum (S n) (S m) = S (minimum n m)\n\npublic export\nmaximum : Nat -> Nat -> Nat\nmaximum Z m = m\nmaximum (S n) Z = S n\nmaximum (S n) (S m) = S (maximum n m)\n\n-- Proofs on S\n\nexport\neqSucc : (0 left, right : Nat) -> left = right -> S left = S right\neqSucc _ _ Refl = Refl\n\nexport\nsuccInjective : (0 left, right : Nat) -> S left = S right -> left = right\nsuccInjective _ _ Refl = Refl\n\n||| A definition of non-zero with a better behaviour than `Not (x = Z)`\n||| This is amenable to proof search and `NonZero Z` is more readily\n||| detected as impossible by Idris\npublic export\ndata NonZero : Nat -> Type where\n SIsNonZero : NonZero (S x)\n\nexport Uninhabited (NonZero Z) where uninhabited SIsNonZero impossible\n\nexport\nSIsNotZ : Not (S x = Z)\nSIsNotZ = absurd\n\n||| Auxiliary function:\n||| mod' fuel a b = a `mod` (S b)\n||| assuming we have enough fuel\npublic export\nmod' : Nat -> Nat -> Nat -> Nat\nmod' Z centre right = centre\nmod' (S fuel) centre right =\n if lte centre right then\n centre\n else\n mod' fuel (minus centre (S right)) right\n\npublic export\nmodNatNZ : Nat -> (y: Nat) -> (0 _ : NonZero y) -> Nat\nmodNatNZ left Z p = void (absurd p)\nmodNatNZ left (S right) _ = mod' left left right\n\nexport partial\nmodNat : Nat -> Nat -> Nat\nmodNat left (S right) = modNatNZ left (S right) SIsNonZero\n\n||| Auxiliary function:\n||| div' fuel a b = a `div` (S b)\n||| assuming we have enough fuel\npublic export\ndiv' : Nat -> Nat -> Nat -> Nat\ndiv' Z centre right = Z\ndiv' (S fuel) centre right =\n if lte centre right then\n Z\n else\n S (div' fuel (minus centre (S right)) right)\n\n-- 'public' to allow type-level division\npublic export\ndivNatNZ : Nat -> (y: Nat) -> (0 _ : NonZero y) -> Nat\ndivNatNZ left (S right) _ = div' left left right\n\nexport partial\ndivNat : Nat -> Nat -> Nat\ndivNat left (S right) = divNatNZ left (S right) SIsNonZero\n\nexport partial\ndivCeilNZ : Nat -> (y: Nat) -> (0 _ : NonZero y) -> Nat\ndivCeilNZ x y p = case (modNatNZ x y p) of\n Z => divNatNZ x y p\n S _ => S (divNatNZ x y p)\n\nexport partial\ndivCeil : Nat -> Nat -> Nat\ndivCeil x (S y) = divCeilNZ x (S y) SIsNonZero\n\n\npublic export\ndivmod' : Nat -> Nat -> Nat -> (Nat, Nat)\ndivmod' Z centre right = (Z, centre)\ndivmod' (S fuel) centre right =\n if lte centre right then\n (Z, centre)\n else\n let qr = divmod' fuel (minus centre (S right)) right\n in (S (fst qr), snd qr)\n\npublic export\ndivmodNatNZ : Nat -> (y: Nat) -> (0 _ : NonZero y) -> (Nat, Nat)\ndivmodNatNZ left (S right) _ = divmod' left left right\n\n\npublic export\nIntegral Nat where\n div = divNat\n mod = modNat\n\nexport partial\ngcd : (a: Nat) -> (b: Nat) -> {auto ok: NotBothZero a b} -> Nat\ngcd a Z = a\ngcd Z b = b\ngcd a (S b) = gcd (S b) (modNatNZ a (S b) SIsNonZero)\n\nexport partial\nlcm : Nat -> Nat -> Nat\nlcm _ Z = Z\nlcm Z _ = Z\nlcm a (S b) = divNat (a * (S b)) (gcd a (S b))\n\n--------------------------------------------------------------------------------\n-- An informative comparison view\n--------------------------------------------------------------------------------\npublic export\ndata CmpNat : Nat -> Nat -> Type where\n CmpLT : (y : _) -> CmpNat x (x + S y)\n CmpEQ : CmpNat x x\n CmpGT : (x : _) -> CmpNat (y + S x) y\n\nexport\ncmp : (x, y : Nat) -> CmpNat x y\ncmp Z Z = CmpEQ\ncmp Z (S k) = CmpLT _\ncmp (S k) Z = CmpGT _\ncmp (S x) (S y) with (cmp x y)\n cmp (S x) (S (x + (S k))) | CmpLT k = CmpLT k\n cmp (S x) (S x) | CmpEQ = CmpEQ\n cmp (S (y + (S k))) (S y) | CmpGT k = CmpGT k\n\n-- Proofs on +\n\nexport\nplusZeroLeftNeutral : (right : Nat) -> 0 + right = right\nplusZeroLeftNeutral _ = Refl\n\nexport\nplusZeroRightNeutral : (left : Nat) -> left + 0 = left\nplusZeroRightNeutral Z = Refl\nplusZeroRightNeutral (S n) = rewrite plusZeroRightNeutral n in Refl\n\nexport\nplusSuccRightSucc : (left, right : Nat) -> S (left + right) = left + (S right)\nplusSuccRightSucc Z _ = Refl\nplusSuccRightSucc (S left) right = rewrite plusSuccRightSucc left right in Refl\n\nexport\nplusCommutative : (left, right : Nat) -> left + right = right + left\nplusCommutative Z right = rewrite plusZeroRightNeutral right in Refl\nplusCommutative (S left) right =\n rewrite plusCommutative left right in\n rewrite plusSuccRightSucc right left in\n Refl\n\nexport\nplusAssociative : (left, centre, right : Nat) ->\n left + (centre + right) = (left + centre) + right\nplusAssociative Z _ _ = Refl\nplusAssociative (S left) centre right =\n rewrite plusAssociative left centre right in Refl\n\nexport\nplusConstantRight : (left, right, c : Nat) -> left = right ->\n left + c = right + c\nplusConstantRight _ _ _ Refl = Refl\n\nexport\nplusConstantLeft : (left, right, c : Nat) -> left = right ->\n c + left = c + right\nplusConstantLeft _ _ _ Refl = Refl\n\nexport\nplusOneSucc : (right : Nat) -> 1 + right = S right\nplusOneSucc _ = Refl\n\nexport\nplusLeftCancel : (left, right, right' : Nat) ->\n left + right = left + right' -> right = right'\nplusLeftCancel Z _ _ p = p\nplusLeftCancel (S left) right right' p =\n plusLeftCancel left right right' (succInjective _ _ p)\n\nexport\nplusRightCancel : (left, left', right : Nat) ->\n left + right = left' + right -> left = left'\nplusRightCancel left left' right p =\n plusLeftCancel right left left' $\n rewrite plusCommutative right left in\n rewrite plusCommutative right left' in\n p\n\nexport\nplusLeftLeftRightZero : (left, right : Nat) ->\n left + right = left -> right = Z\nplusLeftLeftRightZero left right p =\n plusLeftCancel left right Z $\n rewrite plusZeroRightNeutral left in\n p\n\nexport\nplusLteMonotoneRight : (p, q, r : Nat) -> q `LTE` r -> (q+p) `LTE` (r+p)\nplusLteMonotoneRight p Z r LTEZero = rewrite plusCommutative r p in\n lteAddRight p\nplusLteMonotoneRight p (S q) (S r) (LTESucc l) = LTESucc $ plusLteMonotoneRight p q r l\n\nexport\nplusLteMonotoneLeft : (p, q, r : Nat) -> q `LTE` r -> (p + q) `LTE` (p + r)\nplusLteMonotoneLeft p q r p_lt_q\n = rewrite plusCommutative p q in\n rewrite plusCommutative p r in\n plusLteMonotoneRight p q r p_lt_q\n\nexport\nplusLteMonotone : {m, n, p, q : Nat} -> m `LTE` n -> p `LTE` q ->\n (m + p) `LTE` (n + q)\nplusLteMonotone left right =\n transitive {rel=LTE}\n (plusLteMonotoneLeft m p q right)\n (plusLteMonotoneRight q m n left)\n\nzeroPlusLeftZero : (a,b : Nat) -> (0 = a + b) -> a = 0\nzeroPlusLeftZero 0 0 Refl = Refl\nzeroPlusLeftZero (S k) b _ impossible\n\nzeroPlusRightZero : (a,b : Nat) -> (0 = a + b) -> b = 0\nzeroPlusRightZero 0 0 Refl = Refl\nzeroPlusRightZero (S k) b _ impossible\n\n-- Proofs on *\n\nexport\nmultZeroLeftZero : (right : Nat) -> Z * right = Z\nmultZeroLeftZero _ = Refl\n\nexport\nmultZeroRightZero : (left : Nat) -> left * Z = Z\nmultZeroRightZero Z = Refl\nmultZeroRightZero (S left) = multZeroRightZero left\n\nexport\nmultRightSuccPlus : (left, right : Nat) ->\n left * (S right) = left + (left * right)\nmultRightSuccPlus Z _ = Refl\nmultRightSuccPlus (S left) right =\n rewrite multRightSuccPlus left right in\n rewrite plusAssociative left right (left * right) in\n rewrite plusAssociative right left (left * right) in\n rewrite plusCommutative right left in\n Refl\n\nexport\nmultLeftSuccPlus : (left, right : Nat) ->\n (S left) * right = right + (left * right)\nmultLeftSuccPlus _ _ = Refl\n\nexport\nmultCommutative : (left, right : Nat) -> left * right = right * left\nmultCommutative Z right = rewrite multZeroRightZero right in Refl\nmultCommutative (S left) right =\n rewrite multCommutative left right in\n rewrite multRightSuccPlus right left in\n Refl\n\nexport\nmultDistributesOverPlusLeft : (left, centre, right : Nat) ->\n (left + centre) * right = (left * right) + (centre * right)\nmultDistributesOverPlusLeft Z _ _ = Refl\nmultDistributesOverPlusLeft (S k) centre right =\n rewrite multDistributesOverPlusLeft k centre right in\n rewrite plusAssociative right (k * right) (centre * right) in\n Refl\n\nexport\nmultDistributesOverPlusRight : (left, centre, right : Nat) ->\n left * (centre + right) = (left * centre) + (left * right)\nmultDistributesOverPlusRight left centre right =\n rewrite multCommutative left (centre + right) in\n rewrite multCommutative left centre in\n rewrite multCommutative left right in\n multDistributesOverPlusLeft centre right left\n\nexport\nmultAssociative : (left, centre, right : Nat) ->\n left * (centre * right) = (left * centre) * right\nmultAssociative Z _ _ = Refl\nmultAssociative (S left) centre right =\n rewrite multAssociative left centre right in\n rewrite multDistributesOverPlusLeft centre (mult left centre) right in\n Refl\n\nexport\nmultOneLeftNeutral : (right : Nat) -> 1 * right = right\nmultOneLeftNeutral right = plusZeroRightNeutral right\n\nexport\nmultOneRightNeutral : (left : Nat) -> left * 1 = left\nmultOneRightNeutral left =\n rewrite multCommutative left 1 in\n multOneLeftNeutral left\n\n-- Proofs on minus\n\nexport\nminusSuccSucc : (left, right : Nat) ->\n minus (S left) (S right) = minus left right\nminusSuccSucc _ _ = Refl\n\nexport\nminusZeroLeft : (right : Nat) -> minus 0 right = Z\nminusZeroLeft _ = Refl\n\nexport\nminusZeroRight : (left : Nat) -> minus left 0 = left\nminusZeroRight Z = Refl\nminusZeroRight (S _) = Refl\n\nexport\nminusZeroN : (n : Nat) -> Z = minus n n\nminusZeroN Z = Refl\nminusZeroN (S n) = minusZeroN n\n\nexport\nminusOneSuccN : (n : Nat) -> S Z = minus (S n) n\nminusOneSuccN Z = Refl\nminusOneSuccN (S n) = minusOneSuccN n\n\nexport\nminusSuccOne : (n : Nat) -> minus (S n) 1 = n\nminusSuccOne Z = Refl\nminusSuccOne (S _) = Refl\n\nexport\nminusPlusZero : (n, m : Nat) -> minus n (n + m) = Z\nminusPlusZero Z _ = Refl\nminusPlusZero (S n) m = minusPlusZero n m\n\nexport\nminusPos : m `LT` n -> Z `LT` minus n m\nminusPos lt = case view lt of\n LTZero => ltZero\n LTSucc lt => minusPos lt\n\nexport\nminusLteMonotone : {p : Nat} -> m `LTE` n -> minus m p `LTE` minus n p\nminusLteMonotone LTEZero = LTEZero\nminusLteMonotone {p = Z} prf@(LTESucc _) = prf\nminusLteMonotone {p = S p} (LTESucc lte) = minusLteMonotone lte\n\nexport\nminusLtMonotone : m `LT` n -> p `LT` n -> minus m p `LT` minus n p\nminusLtMonotone mltn pltn = case view pltn of\n LTZero => rewrite minusZeroRight m in mltn\n LTSucc pltn => case view mltn of\n LTZero => minusPos pltn\n LTSucc mltn => minusLtMonotone mltn pltn\n\npublic export\nminusPlus : (m : Nat) -> minus (plus m n) m === n\nminusPlus Z = irrelevantEq (minusZeroRight n)\nminusPlus (S m) = minusPlus m\n\nexport\nplusMinusLte : (n, m : Nat) -> LTE n m -> (minus m n) + n = m\nplusMinusLte Z m _ = rewrite minusZeroRight m in\n plusZeroRightNeutral m\nplusMinusLte (S _) Z lte = absurd lte\nplusMinusLte (S n) (S m) lte = rewrite sym $ plusSuccRightSucc (minus m n) n in\n cong S $ plusMinusLte n m (fromLteSucc lte)\n\nexport\nminusMinusMinusPlus : (left, centre, right : Nat) ->\n minus (minus left centre) right = minus left (centre + right)\nminusMinusMinusPlus Z Z _ = Refl\nminusMinusMinusPlus (S _) Z _ = Refl\nminusMinusMinusPlus Z (S _) _ = Refl\nminusMinusMinusPlus (S left) (S centre) right =\n rewrite minusMinusMinusPlus left centre right in Refl\n\nexport\nplusMinusLeftCancel : (left, right : Nat) -> (right' : Nat) ->\n minus (left + right) (left + right') = minus right right'\nplusMinusLeftCancel Z _ _ = Refl\nplusMinusLeftCancel (S left) right right' =\n rewrite plusMinusLeftCancel left right right' in Refl\n\nexport\nmultDistributesOverMinusLeft : (left, centre, right : Nat) ->\n (minus left centre) * right = minus (left * right) (centre * right)\nmultDistributesOverMinusLeft Z Z _ = Refl\nmultDistributesOverMinusLeft (S left) Z right =\n rewrite minusZeroRight (right + (left * right)) in Refl\nmultDistributesOverMinusLeft Z (S _) _ = Refl\nmultDistributesOverMinusLeft (S left) (S centre) right =\n rewrite multDistributesOverMinusLeft left centre right in\n rewrite plusMinusLeftCancel right (left * right) (centre * right) in\n Refl\n\nexport\nmultDistributesOverMinusRight : (left, centre, right : Nat) ->\n left * (minus centre right) = minus (left * centre) (left * right)\nmultDistributesOverMinusRight left centre right =\n rewrite multCommutative left (minus centre right) in\n rewrite multDistributesOverMinusLeft centre right left in\n rewrite multCommutative centre left in\n rewrite multCommutative right left in\n Refl\n\nexport\nzeroMultEitherZero : (a,b : Nat) -> a*b = 0 -> Either (a = 0) (b = 0)\nzeroMultEitherZero 0 b prf = Left Refl\nzeroMultEitherZero (S a) b prf = Right $ zeroPlusLeftZero b (a * b) (sym prf)\n\n-- power proofs\n\n-- multPowerPowerPlus : (base, exp, exp' : Nat) ->\n-- power base (exp + exp') = (power base exp) * (power base exp')\n-- multPowerPowerPlus base Z exp' =\n-- rewrite sym $ plusZeroRightNeutral (power base exp') in Refl\n-- multPowerPowerPlus base (S exp) exp' =\n-- rewrite multPowerPowerPlus base exp exp' in\n-- rewrite sym $ multAssociative base (power base exp) (power base exp') in\n-- Refl\n\n--powerOneNeutral : (base : Nat) -> power base 1 = base\n--powerOneNeutral base = rewrite multCommutative base 1 in multOneLeftNeutral base\n--\n--powerOneSuccOne : (exp : Nat) -> power 1 exp = 1\n--powerOneSuccOne Z = Refl\n--powerOneSuccOne (S exp) = rewrite powerOneSuccOne exp in Refl\n--\n--powerPowerMultPower : (base, exp, exp' : Nat) ->\n-- power (power base exp) exp' = power base (exp * exp')\n--powerPowerMultPower _ exp Z = rewrite multZeroRightZero exp in Refl\n--powerPowerMultPower base exp (S exp') =\n-- rewrite powerPowerMultPower base exp exp' in\n-- rewrite multRightSuccPlus exp exp' in\n-- rewrite sym $ multPowerPowerPlus base exp (exp * exp') in\n-- Refl\n\n-- minimum / maximum proofs\n\nexport\nmaximumAssociative : (l, c, r : Nat) ->\n maximum l (maximum c r) = maximum (maximum l c) r\nmaximumAssociative Z _ _ = Refl\nmaximumAssociative (S _) Z _ = Refl\nmaximumAssociative (S _) (S _) Z = Refl\nmaximumAssociative (S k) (S j) (S i) = rewrite maximumAssociative k j i in Refl\n\nexport\nmaximumCommutative : (l, r : Nat) -> maximum l r = maximum r l\nmaximumCommutative Z Z = Refl\nmaximumCommutative Z (S _) = Refl\nmaximumCommutative (S _) Z = Refl\nmaximumCommutative (S k) (S j) = rewrite maximumCommutative k j in Refl\n\nexport\nmaximumIdempotent : (n : Nat) -> maximum n n = n\nmaximumIdempotent Z = Refl\nmaximumIdempotent (S k) = cong S $ maximumIdempotent k\n\nexport\nminimumAssociative : (l, c, r : Nat) ->\n minimum l (minimum c r) = minimum (minimum l c) r\nminimumAssociative Z _ _ = Refl\nminimumAssociative (S _) Z _ = Refl\nminimumAssociative (S _) (S _) Z = Refl\nminimumAssociative (S k) (S j) (S i) = rewrite minimumAssociative k j i in Refl\n\nexport\nminimumCommutative : (l, r : Nat) -> minimum l r = minimum r l\nminimumCommutative Z Z = Refl\nminimumCommutative Z (S _) = Refl\nminimumCommutative (S _) Z = Refl\nminimumCommutative (S k) (S j) = rewrite minimumCommutative k j in Refl\n\nexport\nminimumIdempotent : (n : Nat) -> minimum n n = n\nminimumIdempotent Z = Refl\nminimumIdempotent (S k) = cong S $ minimumIdempotent k\n\nexport\nminimumZeroZeroLeft : (left : Nat) -> minimum left 0 = Z\nminimumZeroZeroLeft left = rewrite minimumCommutative left 0 in Refl\n\nexport\nminimumSuccSucc : (left, right : Nat) ->\n minimum (S left) (S right) = S (minimum left right)\nminimumSuccSucc _ _ = Refl\n\nexport\nmaximumZeroNLeft : (left : Nat) -> maximum left Z = left\nmaximumZeroNLeft left = rewrite maximumCommutative left Z in Refl\n\nexport\nmaximumSuccSucc : (left, right : Nat) ->\n S (maximum left right) = maximum (S left) (S right)\nmaximumSuccSucc _ _ = Refl\n\nexport\nsucMaxL : (l : Nat) -> maximum (S l) l = (S l)\nsucMaxL Z = Refl\nsucMaxL (S l) = cong S $ sucMaxL l\n\nexport\nsucMaxR : (l : Nat) -> maximum l (S l) = (S l)\nsucMaxR Z = Refl\nsucMaxR (S l) = cong S $ sucMaxR l\n\nexport\nsucMinL : (l : Nat) -> minimum (S l) l = l\nsucMinL Z = Refl\nsucMinL (S l) = cong S $ sucMinL l\n\nexport\nsucMinR : (l : Nat) -> minimum l (S l) = l\nsucMinR Z = Refl\nsucMinR (S l) = cong S $ sucMinR l\n\n-- Algebra -----------------------------\n\nnamespace Semigroup\n\n public export\n [Maximum] Semigroup Nat where\n (<+>) = max\n\n public export\n [Minimum] Semigroup Nat where\n (<+>) = min\n\nnamespace Monoid\n\n public export\n [Maximum] Monoid Nat using Semigroup.Maximum where\n neutral = 0\n", "meta": {"hexsha": "c72d755753a11092a3920c374d0b45a534194f9f", "size": 22659, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/base/Data/Nat.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/Nat.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/Nat.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": 28.1828358209, "max_line_length": 89, "alphanum_fraction": 0.6641069774, "num_tokens": 7543, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110203, "lm_q2_score": 0.7956581049086031, "lm_q1q2_score": 0.5816726739256217}}
{"text": "module Main\n\nimport Common.Util\nimport Common.Interfaces\nimport Specifications.DiscreteOrderedGroup\nimport Specifications.OrderedRing\nimport Proofs.GroupTheory\nimport Proofs.TranslationInvarianceTheory\nimport Proofs.DiscreteOrderTheory\nimport Proofs.Interval\nimport Instances.Notation\nimport Instances.TrustInteger\nimport Instances.ZZ\nimport Addition.Carry\nimport Addition.Absorb\nimport Addition.Reduce\n\n%default total\n\ntestCarry : Integer -> String\ntestCarry x =\n case decideBetween {leq = IntegerLeq} (-18) 18 x of\n Yes inRange => show $ result $\n computeCarry integerDiscreteOrderedGroup 9 (CheckIntegerLeq Oh) x inRange\n No _ => \"Error\"\n\ntestCarryZZ : ZZ -> String\ntestCarryZZ x =\n case decideBetween {leq = LTEZ} (-18) 18 x of\n Yes inRange => show $ result $\n computeCarry zzDiscreteOrderedGroup 9 bound x inRange\n No _ => \"Error\"\n where\n bound : LTEZ 1 8\n bound = LtePosPos (LTESucc LTEZero)\n\nintegerDigits : Vect n Integer -> Maybe (Vect n (Digit IntegerLeq Ng 18))\nintegerDigits = maybeDigits {leq = IntegerLeq} Ng 18\n\ntestAddition : Vect (S k) (Digit {s = Integer} IntegerLeq Ng 18) -> \n (Carry, Vect (S k) Integer)\ntestAddition inputs = outputs $ \n reduce integerDiscreteOrderedRing 9 (CheckIntegerLeq Oh) inputs\n\nmain : IO ()\nmain = do printLn $ map testCarry [(-20)..20]\n printLn $ map testCarryZZ (map fromInteger [(-21)..21])\n printLn $ liftA testAddition \n (integerDigits (reverse [17,2,13,4,5,-15,0]))\n\n||| compile time test\ntest1 : testCarryZZ (-15) = testCarry (-15)\ntest1 = Refl\n\n||| compile time test\ntest2 : testCarryZZ 12 = \"(P, 2)\"\ntest2 = Refl\n", "meta": {"hexsha": "00f27d2427f809f785d67db07747180d0e44211d", "size": 1640, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Main.idr", "max_stars_repo_name": "jeroennoels/verified-exact-real", "max_stars_repo_head_hexsha": "77ad54fe7d0b0058926b92d1c38937ed48d5dd6c", "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/Main.idr", "max_issues_repo_name": "jeroennoels/verified-exact-real", "max_issues_repo_head_hexsha": "77ad54fe7d0b0058926b92d1c38937ed48d5dd6c", "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/Main.idr", "max_forks_repo_name": "jeroennoels/verified-exact-real", "max_forks_repo_head_hexsha": "77ad54fe7d0b0058926b92d1c38937ed48d5dd6c", "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.275862069, "max_line_length": 79, "alphanum_fraction": 0.7182926829, "num_tokens": 479, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677660619633, "lm_q2_score": 0.6859494614282923, "lm_q1q2_score": 0.5816630324387558}}
{"text": "import Data.Vect\n\nallLengths : Vect len String -> Vect len Nat\nallLengths [] = []\nallLengths (word :: words) = length word :: allLengths words\n", "meta": {"hexsha": "a320e7270708b7f19e16e78083580639db0cf5a0", "size": 143, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "ch3/WordLength.idr", "max_stars_repo_name": "Andrewp2/idris-book", "max_stars_repo_head_hexsha": "632910551f3f1646607aa12a7a089164eae945fb", "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": "ch3/WordLength.idr", "max_issues_repo_name": "Andrewp2/idris-book", "max_issues_repo_head_hexsha": "632910551f3f1646607aa12a7a089164eae945fb", "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": "ch3/WordLength.idr", "max_forks_repo_name": "Andrewp2/idris-book", "max_forks_repo_head_hexsha": "632910551f3f1646607aa12a7a089164eae945fb", "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.8333333333, "max_line_length": 60, "alphanum_fraction": 0.7062937063, "num_tokens": 40, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.782662489091802, "lm_q2_score": 0.7431680086124811, "lm_q1q2_score": 0.5816497234340422}}
{"text": "data Vect : Nat -> Type -> Type where \n Nil : Vect Z a \n (::) : a -> (1 xs : Vect k a) -> Vect (S k) a \n \npartial\nappend : (1 _ : Vect n a) -> Vect m a -> Vect (n + m) a \nappend (x :: zs@(y :: ws)) ys = ?foo -- zs usable, y+ws not \n \ncappend : (1 _ : Vect n a) -> Vect m a -> Vect (plus n m) $a \ncappend xs ys \n = case xs of \n Nil => ys \n x :: zs => ?bar -- zs usable, xs not \n \ncappend2 : (1 _ : Vect n a) -> Vect m a -> Vect (plus n m) a \ncappend2 xs ys \n = case xs of \n Nil => ys \n x :: zs => let ts = zs in ?baz -- ts usable, xs+zs not \n", "meta": {"hexsha": "88cd6b17a38fc61cd1f109d509bc36265d279326", "size": 595, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/idris2/linear009/qtt.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/linear009/qtt.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/linear009/qtt.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": 29.75, "max_line_length": 66, "alphanum_fraction": 0.4672268908, "num_tokens": 205, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772286044095, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.5816202112738761}}
{"text": "-- This is based on the David Christianen's port of QuickCheck to Idris 1\n\nmodule Example.Random\n\nimport Data.Fin\n\n%default total\n\n--------------------------------\n--- Interface for seed types ---\n--------------------------------\n\npublic export\ninterface RandomGen g where\n next : g -> (Int, g)\n genRange : g -> (Int,Int)\n split : g -> (g, g)\n\n--------------------------------\n--- Example of the seed type ---\n--------------------------------\n\nexport\ndata StdGen = MkStdGen Int Int\n\nexport\nsomeStdGen : StdGen\nsomeStdGen = MkStdGen 23462 254334222987\n\nexport\nShow StdGen where\n show (MkStdGen i j) = \"MkStdGen \" ++ show i ++ \" \" ++ show j\n\n-- Blatantly stolen from Haskell\nexport\nRandomGen StdGen where\n next (MkStdGen s1 s2) =\n let k : Int = s1 `div` 53668 in\n let s1' : Int = 40014 * (s1 - k * 53668) - k * 12211 in\n let s1'' : Int = if s1' < 0 then s1' + 2147483563 else s1' in\n let k' : Int = s2 `div` 52774 in\n let s2' : Int = 40692 * (s2 - k' * 52774) - k' * 3791 in\n let s2'' : Int = if s2' <= 0 then s2' + 2147483399 else s2' in\n let z : Int = s1'' - s2'' in\n let z' : Int = if z < 1 then z + 2147483562 else z in\n (z', MkStdGen s1'' s2'')\n\n genRange _ = (0, 2147483562)\n split (MkStdGen s1 s2) =\n let gen' : StdGen = snd (next (MkStdGen s1 s2)) in\n let t1 : Int = case gen' of { MkStdGen a b => a } in\n let t2 : Int = case gen' of { MkStdGen a b => b } in\n let new_s1 : Int = if s1 >= 2147483562 || s1 < 1\n then 1\n else s1 + 1 in\n let new_s2 : Int = if s2 <= 1 || s2 >= 2147483398\n then 2147483398\n else s2 - 1 in\n let left : StdGen = MkStdGen (new_s1 - 1) t2 in\n let right : StdGen = MkStdGen t1 (new_s2 + 1) in\n (left, right)\n\n--------------------------------------------------------\n--- Types for which values can be randomly generated ---\n--------------------------------------------------------\n\npublic export\ninterface Random a where\n randomR : RandomGen g => (a, a) -> g -> (a, g)\n random : RandomGen g => g -> (a, g)\n\n--- Random Int ---\n\nexport\nRandom Int where\n random gen = next gen\n randomR (lo, hi) gen = if lo > hi\n then assert_total $ randomR (hi, lo) gen\n else case (f n 1 gen) of\n (v, gen') => ((lo + v `mod` k), gen')\n where\n k : Int\n k = hi - lo + 1\n -- ERROR: b here (2^31-87) represents a baked-in assumption about genRange:\n b : Int\n b = 2147483561\n\n iLogBase : Int -> Int\n iLogBase i = if i < b then 1 else 1 + iLogBase (assert_smaller i (i `div` b))\n\n n : Int\n n = iLogBase k\n\n -- Here we loop until we've generated enough randomness to cover the range:\n f : Int -> Int -> g -> (Int, g)\n f 0 acc g = (acc, g)\n f n' acc g =\n let (x,g') = next g in\n -- We shift over the random bits generated thusfar (* b) and add in the new ones.\n f (assert_smaller n' $ n' - 1) (x + acc * b) g'\n\n--- Random Nat ---\n\nintToNat : Int -> Nat\nintToNat = fromInteger . cast\n\nexport\nRandom Nat where\n randomR (lo, hi) = mapFst intToNat . randomR (cast lo, cast hi)\n random = mapFst intToNat . random\n\n--- Random Unit ---\n\nexport\nRandom Unit where\n randomR ((), ()) gen = ((), snd $ next gen)\n random gen = ((), snd $ next gen)\n\n--- Random Fin ---\n\nfinToInt : Fin n -> Int\nfinToInt = fromInteger . cast\n\nintToFin : (n : Nat) -> Int -> Fin (S n)\nintToFin n = restrict n . cast\n\nexport\n{n : Nat} -> Random (Fin (S n)) where\n randomR (lo, hi) gen = mapFst (intToFin n) $ randomR (finToInt lo, finToInt hi) gen\n random = mapFst (intToFin n) . random\n\n--- Random Char ---\n\nexport\nRandom Char where\n randomR (lo, hi) = mapFst chr . randomR (ord lo, ord hi)\n random = mapFst chr . random\n\n--- Random Bool ---\n\nboolToInt : Bool -> Int\nboolToInt True = 1\nboolToInt False = 0\n\nintToBoolUni : Int -> Bool\nintToBoolUni x = x `mod` 2 == 0\n\nexport\nRandom Bool where\n randomR (lo, hi) = mapFst intToBoolUni . randomR (boolToInt lo, boolToInt hi)\n random = mapFst intToBoolUni . random\n", "meta": {"hexsha": "55c38c2eae981461e8593ed9a0bf1a9f437036d0", "size": 4116, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "2020.11.24-to-complex-data-gen-presentation/src/Example/Random.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/Random.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/Random.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": 27.0789473684, "max_line_length": 89, "alphanum_fraction": 0.5417881438, "num_tokens": 1332, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.798186787341014, "lm_q2_score": 0.7279754548076477, "lm_q1q2_score": 0.5810603895360298}}
{"text": "-- exercises in \"Type-Driven Development with Idris\"\n-- chapter 13, section 2\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\ndoBinOp : (Integer -> Integer -> Integer) -> StackCmd () (S (S height)) (S height)\ndoBinOp op = do val1 <- Pop\n val2 <- Pop\n Push $ op val1 val2\n\ndoNegate : StackCmd () (S height) (S height)\ndoNegate = do val <- Pop\n Push $ -val\n\ndoDiscard : StackCmd () (S height) (height)\ndoDiscard = do val <- Pop\n Pure ()\n\ndoDuplicate : StackCmd () (S height) (S (S height))\ndoDuplicate = do val <- Top\n Push val\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 | Subtract\n | Multiply\n | Negate\n | Discard\n | Duplicate\n\nstrToInput : String -> Maybe StkInput\nstrToInput \"\" = Nothing\nstrToInput \"add\" = Just Add\nstrToInput \"subtract\" = Just Subtract\nstrToInput \"multiply\" = Just Multiply\nstrToInput \"negate\" = Just Negate\nstrToInput \"discard\" = Just Discard\nstrToInput \"duplicate\" = Just Duplicate\nstrToInput x = if all isDigit (unpack x)\n then Just (Number (cast x))\n else Nothing\n\nmutual\n tryBinOp : (op : Integer -> Integer -> Integer) -> StackIO h\n tryBinOp {h = (S (S k))} op\n = do (doBinOp op)\n result <- Top\n PutStr (show result ++ \"\\n\")\n stackCalc\n tryBinOp _\n = do PutStr \"Fewer than two items on the stack\\n\"\n stackCalc\n\n tryNegate : StackIO h\n tryNegate {h = (S k)}\n = do doNegate\n result <- Top\n PutStr (show result ++ \"\\n\")\n stackCalc\n tryNegate\n = do PutStr \"Fewer than one item on the stack\\n\"\n stackCalc\n\n tryDiscard : StackIO h\n tryDiscard {h = (S k)}\n = do result <- Top\n doDiscard\n PutStr (\"Discarded \" ++ show result ++ \"\\n\")\n stackCalc\n tryDiscard\n = do PutStr \"Fewer than one item on the stack\\n\"\n stackCalc\n\n tryDuplicate : StackIO h\n tryDuplicate {h = (S k)}\n = do doDuplicate\n result <- Top\n PutStr (\"Duplicated \" ++ show result ++ \"\\n\")\n stackCalc\n tryDuplicate\n = do PutStr \"Fewer than one item 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 => tryBinOp (+)\n Just Subtract => tryBinOp (flip (-))\n Just Multiply => tryBinOp (*)\n Just Negate => tryNegate\n Just Discard => tryDiscard\n Just Duplicate => tryDuplicate\n\npartial\nmain : IO ()\nmain = run forever [] stackCalc\n", "meta": {"hexsha": "f05c7d9bb65f71922af9bc92a1aa97b68499c762", "size": 4321, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "chapter13/exercises_2.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_2.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_2.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": 28.6158940397, "max_line_length": 82, "alphanum_fraction": 0.5512612821, "num_tokens": 1193, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267118111485244, "lm_q2_score": 0.7025300636233415, "lm_q1q2_score": 0.5807899012843407}}
{"text": "-- ------------------------------------------------------- [ StateMachines.idr ]\n-- Module : Exercises.StateMachines\n-- Description : Solutions to the Chapter 13 exercises in Edwin Brady's\n-- book, \"Type-Driven Development with Idris.\"\n-- --------------------------------------------------------------------- [ EOH ]\nmodule Exercises.StateMachines\n\nimport public Chapter.StateMachines\n\n%access export\n\n-- -------------------------------------------------------- [ 13.1.5 Exercises ]\n\npublic export\ndata GuessCmd : Type -> Nat -> Nat -> Type where\n Try : Integer -> GuessCmd Ordering (S n) n\n\n Pure : ty -> GuessCmd ty state state\n (>>=) : GuessCmd a state1 state2 ->\n (a -> GuessCmd b state2 state3) ->\n GuessCmd b state1 state3\n\nexport\nthreeGuesses : GuessCmd () 3 0\nthreeGuesses = do Try 10\n Try 20\n Try 15\n Pure ()\n\n-- NOTE: noGuesses should not type check.\n-- noGuesses : GuessCmd () 0 0\n-- noGuesses = do Try 10\n-- Pure ()\n\nnamespace Matter\n\n public export\n data Matter = Solid | Liquid | Gas\n\n public export\n data MatterCmd : (ty : Type) ->\n (beforeState, afterState : Matter) ->\n Type where\n Melt : MatterCmd () Solid Liquid\n Boil : MatterCmd () Liquid Gas\n Condense : MatterCmd () Gas Liquid\n Freeze : MatterCmd () Liquid Solid\n\n Pure : ty -> MatterCmd ty state state\n (>>=) : MatterCmd a state1 state2 ->\n (a -> MatterCmd b state2 state3) ->\n MatterCmd b state1 state3\n\nexport\niceSteam : MatterCmd () Solid Gas\niceSteam = do Melt\n Boil\n\nexport\nsteamIce : MatterCmd () Gas Solid\nsteamIce = do Condense\n Freeze\n\n-- NOTE: overMelt should not type check.\n-- overMelt : MatterCmd () Solid Gas\n-- overMelt = do Melt\n-- Melt\n\n-- --------------------------------------------------------------------- [ EOF ]\n", "meta": {"hexsha": "45f1856c4646f5e84a7987e1ca3cefe5bee3f136", "size": 1974, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Exercises/StateMachines.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/StateMachines.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/StateMachines.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": 28.2, "max_line_length": 80, "alphanum_fraction": 0.509118541, "num_tokens": 453, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.7690802423634961, "lm_q1q2_score": 0.5805902010639911}}
{"text": "import Data.Vect\nimport Control.Monad.State\nimport Control.Monad.Identity\n\nVThing : Type\nVThing = {n : Nat} -> Vect n Int -> Int\n\nfoo : Int -> Vect m Int -> ({n : Nat} -> Vect n Int -> Int) -> Int\nfoo x xs f = x + f xs\n\nfoo' : Int -> Vect m Int -> VThing -> Int\nfoo' x xs f = x + f xs\n\nbar : Int -> VThing\nbar y [] = 0\nbar y (x :: xs) = y + x + bar y xs\n\nvsum : Vect n Int -> Int\nvsum [] = 0\nvsum (x :: xs) = x + vsum xs\n\ntestfoo : Vect n Int -> Int\ntestfoo xs = foo 42 xs (\\ xs => vsum xs)\n\ntestfoo2 : Vect n Int -> Int\ntestfoo2 xs = foo' 42 xs vsum\n\ntestfoo3 : Vect n Int -> Int\ntestfoo3 xs = foo 42 xs (bar 10)\n\nAnyST : Type -> Type -> Type\nAnyST s a = {m : _} -> Monad m => StateT s m a\n\n-- foost : AnyST Int ()\nfoost : StateT Int Maybe ()\nfoost = do x <- get\n put x\n\nwibble : StateT Int Maybe ()\nwibble = foost\n\nappShow : Show a => ({b : _} -> Show b => b -> String) -> a -> String\nappShow s x = s x\n\nmyshow : Show a => a -> String\nmyshow = show\n\nbaz : Int -> String\nbaz x = appShow myshow x ++ appShow show x\n\ntupleId : ({a : _} -> a -> a) -> (a, b) -> (a, b)\ntupleId f (a, b) = (f a, f b)\n\nAppendType : Type\nAppendType = {a, n, m : _} -> Vect n a -> Vect m a -> Vect (n + m) a\n\nappend : AppendType\nappend [] ys = ys\nappend (x :: xs) ys = x :: append xs ys\n\nmain : IO ()\nmain = do putStrLn (baz 42)\n printLn (append [1,2,3] [4,5,6])\n", "meta": {"hexsha": "0a7e6fcf626e270172e240fca0f890f122a25d97", "size": 1358, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "test/idris-dev/basic012/basic012.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/basic012/basic012.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/basic012/basic012.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": 21.21875, "max_line_length": 69, "alphanum_fraction": 0.5603829161, "num_tokens": 494, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696748, "lm_q2_score": 0.7341195327172402, "lm_q1q2_score": 0.5803437481405926}}
{"text": "module Flexidisc.OrdList.Label\n\nimport Flexidisc.OrdList.Type\n\n%default total\n%access public export\n\n||| Proof that a label is in an `OrdList`\ndata OrdLabel : (l : k) -> (xs : OrdList k o v) -> Type where\n ||| The label is in the first element of the list\n Here : OrdLabel l ((l,v)::xs)\n ||| The label is in the tail\n There : (later : OrdLabel l xs) -> OrdLabel l (x::xs)\n\n%name OrdLabel lbl, loc, prf, e, elem\n\n||| Given a proof that a label is in the list, get the corresponding value back\natLabel : (xs : OrdList k o v) -> (loc : OrdLabel l xs) -> v\natLabel ((_, v) :: _) Here = v\natLabel (_ :: xs) (There later) = atLabel xs later\n\nUninhabited (OrdLabel k []) where\n uninhabited Here impossible\n uninhabited (There _) impossible\n\n||| Decide whether a label is in a list or not\ndecLabel : DecEq k => (l : k) -> (xs : OrdList k o v) -> Dec (OrdLabel l xs)\ndecLabel l [] = No uninhabited\ndecLabel l ((kx, vx) :: xs) with (decEq l kx)\n | (Yes prf) = Yes (rewrite prf in Here)\n | (No contraHere) with (decLabel l xs)\n | (Yes prf) = Yes (There prf)\n | (No contraThere) = No (\\p => case p of\n Here => contraHere Refl\n There later => contraThere later)\n\n||| Given a proof that an element is in a vector, remove it\ndropLabel : (xs : OrdList k o v) -> (loc : OrdLabel l xs) -> OrdList k o v\ndropLabel (_ :: xs) Here = xs\ndropLabel (x :: xs) (There later) = x :: dropLabel xs later\n\n||| Update a value in the list given it's location and a new value\nchangeValue : (xs : OrdList k o v) -> (loc : OrdLabel l xs) ->\n (new : v) -> OrdList k o v\nchangeValue ((x, old) :: xs) Here new = (x, new) :: xs\nchangeValue (x :: xs) (There later) new = x :: changeValue xs later new\n", "meta": {"hexsha": "3ed6b78457486ae8304a15898ac6a70be74ea57b", "size": 1795, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Flexidisc/OrdList/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/OrdList/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/OrdList/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": 38.1914893617, "max_line_length": 79, "alphanum_fraction": 0.6022284123, "num_tokens": 552, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.5802887783727229}}
{"text": "module xquant.Spinor.Sigmas\n\nimport public Control.Algebra\n\ninfixr 5 <>\ninfixr 7 <&>\n\n-------------------------------------------------------------------------------------------\n-- Data for Sigma Operators • Complex signs (Phases)\n-- • Pauli operators\n-- • Higher Sigma operators\n-- (tensor products of Paulis with an overall phase)\n-------------------------------------------------------------------------------------------\n\n||| 4 primative complex phases, (+1), (+i), (-1), (-i),\n||| bools represent minus sign and i presence respectively\ndata Phase : Type where\n Sign : (minus : Bool) -> (i : Bool) -> Phase\n\ninstance Show Phase where\n show (Sign False False) = \"+1\"\n show (Sign False True) = \"+i\"\n show (Sign True False) = \"-1\"\n show (Sign True True) = \"-i\"\n\ninstance Eq Phase where\n (==) (Sign m1 i1) (Sign m2 i2) = (m1 == m2) && (i1 == i2)\n\n\n-- Exclusive OR\nxor : Bool -> Bool -> Bool\nxor a b = if a then not b else b\n\ninstance Semigroup Phase where\n (<+>) (Sign as ai) (Sign bs bi) = Sign (xor (ai && bi) $ xor as bs) (xor ai bi)\n\ninstance Monoid Phase where\n neutral = Sign False False\n\ninstance Group Phase where\n inverse (Sign a b) = Sign (xor a b) b\n\nstar : Phase -> Phase\nstar (Sign a b) = Sign a (not b)\n\n-- Phase Shorthands - Capital 'P' for phases\nP1 : Phase\nP1 = Sign False False\nPi : Phase\nPi = Sign False True\nM1 : Phase\nM1 = Sign True False\nMi : Phase\nMi = Sign True True\n\n\n-- Pauli Data – Capital 'S' for basic sigma operators\ndata Pauli = SI | SX | SY | SZ\n\ninstance Show Pauli where\n show SI = \"I\"\n show SX = \"x\"\n show SY = \"y\"\n show SZ = \"z\" -- should be \"σz\" whene idris can print non-8-bit characters\n\ninstance Eq Pauli where\n SI == SI = True\n SX == SX = True\n SY == SY = True\n SZ == SZ = True\n _ == _ = False\n\n\n-- Higher Sigma operator datatype, indexed by Nat\ndata Sigma : Nat -> Type where\n sPhase : Phase -> Sigma Z\n Sig : Pauli -> Sigma k -> Sigma (S k)\n\ninstance Show (Sigma n) where\n show (sPhase phase) = show phase\n show s = (Prefix s) ++ \"[\" ++ (suffix s) ++ \"]\" where\n suffix : Sigma n -> String\n suffix (sPhase ph) = \"\"\n suffix (Sig p (sPhase ph)) = (show p)\n suffix (Sig p s) = (show p) ++ (suffix s)\n Prefix : Sigma n -> String\n Prefix (sPhase (Sign a b)) = (if a then \"-\" else \"\") ++ (if b then \"i \" else \"\")\n Prefix (Sig p s) = Prefix s\n\n\n-- 4 Standard Sigma 1s\nsX : (Sigma 1)\nsX = Sig SX $ sPhase P1\n\nsY : Sigma 1\nsY = Sig SY $ sPhase P1\n\nsZ : Sigma 1\nsZ = Sig SZ $ sPhase P1\n\nsI : Sigma 1\nsI = Sig SI $ sPhase P1\n\n\n-------------------------------------------------------------------------------------------\n-- Operations with Sigmas • Helper functions: getPhase, topPauli, lastPauli, pack\n-- • Scalar multiply\n-- • (Single) Sigma multiply\n-- • (Higher) Sigma multiply\n-------------------------------------------------------------------------------------------\n\n-- Extract the Phase, first Pauli or last Pauli from a Sigma\ngetPhase : Sigma n -> Phase\ngetPhase (sPhase p) = p\ngetPhase (Sig p s) = getPhase s\n\ntopPauli : Sigma (S k) -> Pauli\ntopPauli (Sig p s) = p\n\nlastPauli : Sigma (S k) -> Pauli\nlastPauli (Sig pl (sPhase ph)) = pl\nlastPauli (Sig pl (Sig pl2 s)) = lastPauli (Sig pl2 s)\n\n-- Pack a Pauli into a Sigma\npack : Pauli -> Sigma 1\npack s = Sig s $ sPhase P1\n\n\n-- Phase times a Sigma\nxPhaseSig.(*) : Phase -> Sigma n -> Sigma n\nxPhaseSig.(*) ph (sPhase ph2) = sPhase $ ph <+> ph2\nxPhaseSig.(*) ph (Sig pl s) = Sig pl $ ph * s\n\nxSigPhase.(*) : Sigma n -> Phase -> Sigma n\nxSigPhase.(*) s p = p * s\n\n-- Single Sigma multiply\ns1Mult : Sigma 1 -> Sigma 1 -> Sigma 1\ns1Mult (Sig x1 $ sPhase p1) (Sig x2 $ sPhase p2) = case x1 of\n SX => case x2 of\n SX => Sig SI (sPhase $ p1 <+> p2)\n SY => Sig SZ (sPhase $ p1 <+> p2 <+> Pi)\n SZ => Sig SY (sPhase $ p1 <+> p2 <+> Mi)\n SI => Sig SX (sPhase $ p1 <+> p2)\n SY => case x2 of\n SY => Sig SI (sPhase $ p1 <+> p2)\n SZ => Sig SX (sPhase $ p1 <+> p2 <+> Pi)\n SX => Sig SZ (sPhase $ p1 <+> p2 <+> Mi)\n SI => Sig SY (sPhase $ p1 <+> p2)\n SZ => case x2 of\n SZ => Sig SI (sPhase $ p1 <+> p2)\n SX => Sig SY (sPhase $ p1 <+> p2 <+> Pi)\n SY => Sig SX (sPhase $ p1 <+> p2 <+> Mi)\n SI => Sig SZ (sPhase $ p1 <+> p2)\n SI => case x2 of\n SI => Sig SI (sPhase $ p1 <+> p2)\n SX => Sig SX (sPhase $ p1 <+> p2)\n SY => Sig SY (sPhase $ p1 <+> p2)\n SZ => Sig SZ (sPhase $ p1 <+> p2)\n\n\n-- Higher Sigma mutiply\nsMult : Sigma n -> Sigma n -> Sigma n\nsMult (sPhase p1) (sPhase p2) = sPhase $ p1 <+> p2\nsMult (Sig pl1 s1) (Sig pl2 s2) with (s1Mult (pack pl1) (pack pl2))\n sMult (Sig pl1 s1) (Sig pl2 s2) | r = Sig (topPauli r) ((getPhase r) * (sMult s1 s2))\n\n-- Infix op for Sigma multiply\n(<>) : Sigma n -> Sigma n -> Sigma n\n(<>) = sMult\n\n\n-- Tensor multiply Sigmas ('otimes', i.e. ⊗ )\nox : Sigma n -> Sigma m -> Sigma (n + m)\nox s (sPhase p) ?= {Sigma_OTimes_Lemma_1} p * s\nox (sPhase p) s = p * s\nox (Sig pl1 s1) (Sig pl2 s2) ?= {Sigma_OTimes_Lemma_2} ox (dropLast $ Sig pl1 s1)\n (Sig (lastPauli $ Sig pl1 s1) (Sig pl2 s2)) where\n dropLast : {k : Nat} -> Sigma (S k) -> Sigma k\n dropLast (Sig pl (sPhase ph)) = (sPhase ph)\n dropLast (Sig pl (Sig pl2 s)) = Sig pl (dropLast (Sig pl2 s))\n\n-- Infix tensor multiply Sigmas\n(<&>) : Sigma n -> Sigma m -> Sigma (n + m)\n(<&>) = ox\n\n-- Tensor powers of a Sigma op\nopower : Sigma n -> (m : Nat) -> Sigma (n * m)\nopower s Z ?= {Sigma_Power_Lemma_1} sPhase P1\nopower s (S n) ?= {Sigma_Power_Lemma_2} s <&> (opower s n)\n\nnegId : (n : Nat) -> Sigma n\nnegId Z = sPhase M1\nnegId (S n) = Sig SI $ negId n\n\n\n---------- Proofs ----------\n\nSigma_OTimes_Lemma_1 = proof\n intro\n rewrite (plusZeroRightNeutral n)\n intros\n trivial\n\nSigma_OTimes_Lemma_2 = proof\n intros\n rewrite sym $ plusSuccRightSucc k (S k1)\n trivial\n\n\nSigma_Power_Lemma_1 = proof\n intros\n rewrite (sym $ multZeroRightZero n)\n trivial\n\nSigma_Power_Lemma_2 = proof\n intros\n rewrite (sym $ multRightSuccPlus n n1)\n trivial\n", "meta": {"hexsha": "65a72f1c59a6f5ba86bbdc194b2238f5501757d1", "size": 7496, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/xquant/Spinor/Sigmas.idr", "max_stars_repo_name": "BlackBrane/xquant", "max_stars_repo_head_hexsha": "b94d87609aa63af2d88b6cca50f85b58a00fc92f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2015-10-31T21:21:40.000Z", "max_stars_repo_stars_event_max_datetime": "2017-01-23T17:42:39.000Z", "max_issues_repo_path": "src/xquant/Spinor/Sigmas.idr", "max_issues_repo_name": "fieldstrength/xquant", "max_issues_repo_head_hexsha": "b94d87609aa63af2d88b6cca50f85b58a00fc92f", "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/xquant/Spinor/Sigmas.idr", "max_forks_repo_name": "fieldstrength/xquant", "max_forks_repo_head_hexsha": "b94d87609aa63af2d88b6cca50f85b58a00fc92f", "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.0727272727, "max_line_length": 107, "alphanum_fraction": 0.4457043757, "num_tokens": 2021, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998508568417, "lm_q2_score": 0.7461389986757757, "lm_q1q2_score": 0.5799737323891537}}
{"text": "scoreGame : List Int -> Int\nscoreGame xs = score xs where\n score : List Int -> Int\n score [] = 0\n score (x::y::[]) = x + y \n score (x::y::z::[]) = x + y + z\n score (x::y::z::xs) = \n if x == 10 then x + y + z + (score (y::z::xs)) \n else if x + y == 10 then x + y + z + (score (z::xs)) \n else x + y + (score (z::xs)) \n\n--\n-- TEST CASES:\n--\n\n-- 300 : Int\nperfect : Int\nperfect = scoreGame [10,10,10,10,10,10,10,10,10,10,10,10] \n\n-- 90 : Int\nnines : Int\nnines = scoreGame [9,0,9,0,9,0,9,0,9,0,9,0,9,0,9,0,9,0,9,0]\n\n-- 150 : Int\nspares : Int\nspares = scoreGame [5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5]\n", "meta": {"hexsha": "df720d31ec0d3d2d18264dfd068e6534195bf4d7", "size": 698, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "katas/002-bowling/andrew.idr", "max_stars_repo_name": "ToJans/idris101", "max_stars_repo_head_hexsha": "c1912a30161be6d9987c40ebe304c8ae7827367e", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 47, "max_stars_repo_stars_event_min_datetime": "2015-01-31T23:32:15.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-22T08:43:07.000Z", "max_issues_repo_path": "katas/002-bowling/andrew.idr", "max_issues_repo_name": "ToJans/idris101", "max_issues_repo_head_hexsha": "c1912a30161be6d9987c40ebe304c8ae7827367e", "max_issues_repo_licenses": ["Unlicense"], "max_issues_count": 5, "max_issues_repo_issues_event_min_datetime": "2015-01-02T14:29:31.000Z", "max_issues_repo_issues_event_max_datetime": "2015-03-12T13:49:41.000Z", "max_forks_repo_path": "katas/002-bowling/andrew.idr", "max_forks_repo_name": "ToJans/idris101", "max_forks_repo_head_hexsha": "c1912a30161be6d9987c40ebe304c8ae7827367e", "max_forks_repo_licenses": ["Unlicense"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2015-01-09T12:22:53.000Z", "max_forks_repo_forks_event_max_datetime": "2018-10-11T09:29:21.000Z", "avg_line_length": 25.8518518519, "max_line_length": 62, "alphanum_fraction": 0.452722063, "num_tokens": 309, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245953120233, "lm_q2_score": 0.6959583250334526, "lm_q1q2_score": 0.5799591895625354}}
{"text": "total sameCons: {xs: List a} -> {ys: List a} -> xs = ys -> x :: xs = x :: ys\nsameCons Refl = Refl\n\ntotal sameLists: {xs: List a} -> {ys: List a} -> x = y -> xs = ys -> x :: xs = y :: ys\nsameLists Refl Refl = Refl\n\ndata ThreeEq: Nat -> Nat -> Nat -> Type where\n Same: (x:Nat) -> ThreeEq x x x\n\ntotal allSameS: (x, y, z: Nat) -> ThreeEq x y z -> ThreeEq (S x) (S y) (S z)\nallSameS x x x (Same x) = Same (S x)", "meta": {"hexsha": "a95679e3abac8d77203b41bb43c1f8619a0597fd", "size": 407, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "ProofExercises_7.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": "ProofExercises_7.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": "ProofExercises_7.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": 37.0, "max_line_length": 86, "alphanum_fraction": 0.5528255528, "num_tokens": 161, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619436290699, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.5792093068476155}}
{"text": "||| Additional utility functions for the `Bifoldable` interface.\nmodule Data.Bifoldable\n\n%default total\n\n||| Left associative monadic bifold over a structure.\npublic export\nbifoldlM : Monad m => Bifoldable p =>\n (f: a -> b -> m a) ->\n (g: a -> c -> m a) ->\n (init: a) ->\n (input: p b c) -> m a\nbifoldlM f g a0 = bifoldl (\\ma,b => ma >>= flip f b)\n (\\ma,c => ma >>= flip g c)\n (pure a0)\n\n||| Combines the elements of a structure,\n||| given ways of mapping them to a common monoid.\npublic export\nbifoldMap : Monoid m => Bifoldable p => (a -> m) -> (b -> m) -> p a b -> m\nbifoldMap f g = bifoldr ((<+>) . f) ((<+>) . g) neutral\n\n||| Combines the elements of a structure using a monoid.\npublic export\nbiconcat : Monoid m => Bifoldable p => p m m -> m\nbiconcat = bifoldr (<+>) (<+>) neutral\n\n||| Combines the elements of a structure,\n||| given ways of mapping them to a common monoid.\npublic export\nbiconcatMap : Monoid m => Bifoldable p => (a -> m) -> (b -> m) -> p a b -> m\nbiconcatMap f g = bifoldr ((<+>) . f) ((<+>) . g) neutral\n\n||| The conjunction of all elements of a structure containing lazy boolean\n||| values. `biand` short-circuits from left to right, evaluating until either an\n||| element is `False` or no elements remain.\npublic export\nbiand : Bifoldable p => p (Lazy Bool) (Lazy Bool) -> Bool\nbiand = bifoldl (&&) (&&) True\n\n||| The disjunction of all elements of a structure containing lazy boolean\n||| values. `bior` short-circuits from left to right, evaluating either until an\n||| element is `True` or no elements remain.\npublic export\nbior : Bifoldable p => p (Lazy Bool) (Lazy Bool) -> Bool\nbior = bifoldl (||) (||) False\n\n||| The disjunction of the collective results of applying a predicate to all\n||| elements of a structure. `biany` short-circuits from left to right.\npublic export\nbiany : Bifoldable p => (a -> Bool) -> (b -> Bool) -> p a b -> Bool\nbiany f g = bifoldl (\\x,y => x || f y) (\\x,y => x || g y) False\n\n||| The disjunction of the collective results of applying a predicate to all\n||| elements of a structure. `biall` short-circuits from left to right.\npublic export\nbiall : Bifoldable p => (a -> Bool) -> (b -> Bool) -> p a b -> Bool\nbiall f g = bifoldl (\\x,y => x && f y) (\\x,y => x && g y) True\n\n||| Add together all the elements of a structure.\npublic export\nbisum : Num a => Bifoldable p => p a a -> a\nbisum = bifoldr (+) (+) 0\n\n||| Add together all the elements of a structure.\n||| Same as `bisum` but tail recursive.\nexport\nbisum' : Num a => Bifoldable p => p a a -> a\nbisum' = bifoldl (+) (+) 0\n\n||| Multiply together all elements of a structure.\npublic export\nbiproduct : Num a => Bifoldable p => p a a -> a\nbiproduct = bifoldr (*) (*) 1\n\n||| Multiply together all elements of a structure.\n||| Same as `product` but tail recursive.\nexport\nbiproduct' : Num a => Bifoldable p => p a a -> a\nbiproduct' = bifoldl (*) (*) 1\n\n||| Map each element of a structure to a computation, evaluate those\n||| computations and discard the results.\npublic export\nbitraverse_ : (Bifoldable p, Applicative f)\n => (a -> f x)\n -> (b -> f y)\n -> p a b\n -> f ()\nbitraverse_ f g = bifoldr ((*>) . f) ((*>) . g) (pure ())\n\n||| Evaluate each computation in a structure and discard the results.\npublic export\nbisequence_ : Applicative f => Bifoldable p => p (f a) (f b) -> f ()\nbisequence_ = bifoldr (*>) (*>) (pure ())\n\n||| Like `bitraverse_` but with the arguments flipped.\npublic export\nbifor_ : (Bifoldable p, Applicative f)\n => p a b\n -> (a -> f x)\n -> (b -> f y)\n -> f ()\nbifor_ p f g = bitraverse_ f g p\n\n||| Bifold 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.\npublic export\nbichoice : Alternative f => Bifoldable p => p (Lazy (f a)) (Lazy (f a)) -> f a\nbichoice t = bifoldr {a = Lazy (f a)} {b = Lazy (f a)} {acc = Lazy (f a)}\n (\\ x, xs => x <|> xs)\n (\\ x, xs => x <|> xs)\n empty\n t\n\n||| A fused version of `bichoice` and `bimap`.\npublic export\nbichoiceMap : (Bifoldable p, Alternative f)\n => (a -> f x)\n -> (b -> f x)\n -> p a b ->\n f x\nbichoiceMap fa fb t = bifoldr {a} {b} {acc = Lazy (f x)}\n (\\e, fx => fa e <|> fx)\n (\\e, fx => fb e <|> fx)\n empty\n t\n", "meta": {"hexsha": "7b2cdbaf38546eac2fc45523720d9c31a18a3702", "size": 4622, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/base/Data/Bifoldable.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/Bifoldable.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/Bifoldable.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.2824427481, "max_line_length": 82, "alphanum_fraction": 0.5824318477, "num_tokens": 1405, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.7122321781307374, "lm_q1q2_score": 0.5789502603147453}}
{"text": "module ProofColDivSeqPostulate\n\nimport ProofColDivSeqBase\n\n%default total\n-- %language ElabReflection\n%access export\n\n%hide Language.Reflection.P\n\n-- from ProofColDivSeqBase\n-- ########################################\npublic export\ndata Limited : CoList Integer -> Type where\n IsLimited00 : (step : Nat ** limitedNStep xs step = True) -> Limited xs\n IsLimited01 : (k : Nat)\n -> Limited $ divSeq (plus (plus k k) k)\n -> Limited $ divSeq (S (plus (plus (plus (plus (plus k k) (plus k k)) (plus k k))\n (S (plus (plus (plus k k) (plus k k))(plus k k))))\n (S (plus (plus (plus k k) (plus k k)) (plus k k)))))\n IsLimited02 : (l : Nat)\n -> Limited (divSeq (plus (plus (plus l l) (plus l l)) (plus l l))) \n -> Limited (divSeq (S (S (plus (plus (plus (plus (plus (plus (plus l l) l) (plus (plus l l) l))\n (S (plus (plus (plus l l) l) (plus (plus l l) l))))\n (S (plus (plus (plus l l) l) (plus (plus l l) l))))\n (S (S (plus (plus (plus (plus (plus l l) l) (plus (plus l l) l))\n (S (plus (plus (plus l l) l) (plus (plus l l) l))))\n (S (plus (plus (plus l l) l) (plus (plus l l) l)))))))\n (S (S (plus (plus (plus (plus (plus l l) l) (plus (plus l l) l))\n (S (plus (plus (plus l l) l) (plus (plus l l) l))))\n (S (plus (plus (plus l l) l) (plus (plus l l) l))))))))))\n IsLimited03 : (l : Nat)\n -> Limited (divSeq (S (S (S (plus (plus (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l)))\n (S (S (S (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l)))))))\n (S (S (S (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l)))))))))))\n -> Limited (divSeq (S (S (S (plus (plus (plus (plus (plus (plus (plus l l) l) (S (plus (plus l l) l)))\n (S (S (plus (plus (plus l l) l) (S (plus (plus l l) l))))))\n (S (S (plus (plus (plus l l) l) (S (plus (plus l l) l))))))\n (S (S (S (plus (plus (plus (plus (plus l l) l) (S (plus (plus l l) l)))\n (S (S (plus (plus (plus l l) l) (S (plus (plus l l) l))))))\n (S (S (plus (plus (plus l l) l) (S (plus (plus l l) l))))))))))\n (S (S (S (plus (plus (plus (plus (plus l l) l) (S (plus (plus l l) l)))\n (S (S (plus (plus (plus l l) l) (S (plus (plus l l) l))))))\n (S (S (plus (plus (plus l l) l) (S (plus (plus l l) l))))))))))))))\n IsLimited04 : (l : Nat)\n -> Limited (divSeq (S (S (S (plus (plus (plus (plus l l) (plus l l))\n (S (S (S (plus (plus l l) (plus l l))))))\n (S (S (S (plus (plus l l) (plus l l))))))))))\n -> Limited (divSeq (S (S (S (S (plus (plus (plus (plus (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))\n (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))\n (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))\n (S (S (S (S (plus (plus (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))\n (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))\n (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l)))))))))))))\n (S (S (S (S (plus (plus (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))\n (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))\n (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))))))))))))\n IsLimited05 : (j : Nat)\n -> Limited (divSeq (plus (plus j j) j))\n -> Limited (divSeq (S (S (plus (plus (plus (plus j j) j) (S (S (plus (plus j j) j))))\n (S (S (plus (plus j j) j)))))))\n IsLimited06 : (l : Nat)\n -> Limited (divSeq (plus (plus l l) l))\n -> Limited (divSeq (S (S (S (plus (plus (plus (plus (plus (plus l l) (plus l l)) (plus (plus l l) (plus l l))) (plus (plus l l) (plus l l)))\n (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)))))))\n (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)))))))))))\n IsLimited07 : (o : Nat)\n -> Limited (divSeq (S (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o))))\n (plus (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o)))))\n (S (S (S (S (S (S (S (plus (plus (plus (plus (plus o o)\n (plus o o)) \n (plus (plus o o) \n (plus o o)))\n (plus (plus (plus o o) \n (plus o o)) \n (plus (plus o o) \n (plus o o)))) \n (plus (plus (plus (plus o o)\n (plus o o)) \n (plus (plus o o) \n (plus o o))) \n (plus (plus (plus o o)\n (plus o o)) \n (plus (plus o o) \n (plus o \n o)))))))))))))\n (S (S (S (S (S (S (S (plus (plus (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o)))\n (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o))))\n (plus (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o)))\n (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o\n o)))))))))))))))))))))\n -> Limited (divSeq (S (S (S (S (plus (plus (plus (plus (plus (plus (plus (plus o o) o)\n (plus (plus o o) o))\n (S (plus (plus (plus o o) o)\n (plus (plus o o) o))))\n (S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (S (plus (plus (plus o o) o)\n (plus (plus o o) o))))))\n (S (plus (plus (plus (plus o o) o) (plus (plus o o) o))\n (S (plus (plus (plus o o) o)\n (plus (plus o o) o))))))\n (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o)\n (plus (plus o o) o))\n (S (plus (plus (plus o o) o)\n (plus (plus o o) o))))\n (S (plus (plus (plus (plus o o) o)\n (plus (plus o o) o))\n (S (plus (plus (plus o o) o)\n (plus (plus o o) o))))))\n (S (plus (plus (plus (plus o o) o)\n (plus (plus o o) o))\n (S (plus (plus (plus o o) o)\n (plus (plus o o) o)))))))))))\n (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o)\n (plus (plus o o) o))\n (S (plus (plus (plus o o) o)\n (plus (plus o o) o))))\n (S (plus (plus (plus (plus o o) o)\n (plus (plus o o) o))\n (S (plus (plus (plus o o) o)\n (plus (plus o o) o))))))\n (S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (S (plus (plus (plus o o) o)\n (plus (plus o o) o))))))))))))))))\n IsLimited08 : (o : Nat)\n -> Limited (divSeq (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))\n (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o)))))))))))))) (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o))\n (plus (plus o o)\n (plus o o))))))))))))))))))))))))\n -> Limited (divSeq (S (S (S (S (S (plus (plus (plus (plus (plus (plus (plus (plus o o) o)\n (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))\n (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))))))\n (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))))))\n (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o)\n (S (plus (plus o o) o))))))\n (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o)\n (S (plus (plus o o) o)))))))))\n (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o)\n (S (plus (plus o o) o)))))))))))))))\n (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))\n (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o)\n (S (plus (plus o o) o)))))))))\n (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o)\n (S (plus (plus o o) o)))))))))))))))))))))\n IsLimited09 : (o : Nat)\n -> Limited $ divSeq (S (S (S (S (S (S (S (plus (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))\n (S (S (S (S (S (S (S (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))))))))))\n (S (S (S (S (S (S (S (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))))))))))))))))\n -> Limited $ divSeq (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))))))\n (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))))))))))))))\n (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o)\n (S (S (plus (plus o o) o)))))))))))))))))))))))))\n IsLimited10 : (o : Nat)\n -> Limited $ divSeq (S (plus (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))\n (S (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))))\n (S (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))))\n -> Limited $ divSeq (S (S (S (S (plus (plus (plus (plus (plus (plus (plus (plus o o) o) (plus (plus o o) o))\n (plus (plus (plus o o) o) (plus (plus o o) o)))\n (S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (plus (plus (plus o o) o) (plus (plus o o) o)))))\n (S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (plus (plus (plus o o) o) (plus (plus o o) o)))))\n (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (plus (plus (plus o o) o) (plus (plus o o) o))) (S (plus (plus (plus (plus o o) o) (plus (plus o o) o))\n (plus (plus (plus o o) o) (plus (plus o o) o)))))\n (S (plus (plus (plus (plus o o) o) (plus (plus o o) o))\n (plus (plus (plus o o) o) (plus (plus o o) o))))))))))\n (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (plus (plus (plus o o) o) (plus (plus o o) o)))\n (S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (plus (plus (plus o o) o) (plus (plus o o) o)))))\n (S (plus (plus (plus (plus o o) o) (plus (plus o o) o))\n (plus (plus (plus o o) o) (plus (plus o o) o))))))))))))))\n IsLimited11 : (o : Nat)\n -> Limited $ divSeq (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))\n (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o))\n (plus (plus o o)\n (plus o o))))\n (plus (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o))) (plus (plus (plus o o) (plus o o))\n (plus (plus o o)\n (plus o o)))))))))))))))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o))))\n (plus (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o))\n (plus (plus o o)\n (plus o o))))))))))))))))))))))))))))))))))))\n -> Limited $ divSeq (S (S (S (S (S (plus (plus (plus (plus (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))\n (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))\n (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))\n (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))\n (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))\n (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))))))))\n (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))\n (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))\n (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))))))))))))))))\n IsLimited12 : (o : Nat)\n -> Limited $ divSeq (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o))))))))))))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus o o) (plus o o))\n (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o))\n (plus (plus o o)\n (plus o o)))))))))))))))))))))))))))))))\n -> Limited $ divSeq (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))))))\n (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))))))))))))\n (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))))))))))))))))))\n IsLimited13 : (o : Nat)\n -> Limited $ divSeq (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))\n (S (S (S (S (S (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))))))))\n (S (S (S (S (S (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))\n (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))))))))))))))\n -> Limited $ divSeq (S (S (S (S (S (plus (plus (plus (plus (plus (plus (plus (plus o o) o) (plus (plus o o) o))\n (S (plus (plus (plus o o) o) (plus (plus o o) o))))\n (S (S (plus (plus (plus (plus o o) o) (plus (plus o o) o))\n (S (plus (plus (plus o o) o) (plus (plus o o) o)))))))\n (S (S (plus (plus (plus (plus o o) o) (plus (plus o o) o)) (S (plus (plus (plus o o) o) (plus (plus o o) o)))))))\n (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (plus (plus o o) o))\n (S (plus (plus (plus o o) o) (plus (plus o o) o))))\n (S (S (plus (plus (plus (plus o o) o) (plus (plus o o) o))\n (S (plus (plus (plus o o) o) (plus (plus o o) o)))))))\n (S (S (plus (plus (plus (plus o o) o) (plus (plus o o) o))\n (S (plus (plus (plus o o) o) (plus (plus o o) o)))))))))))))\n (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (plus (plus o o) o))\n (S (plus (plus (plus o o) o) (plus (plus o o) o))))\n (S (S (plus (plus (plus (plus o o) o) (plus (plus o o) o))\n (S (plus (plus (plus o o) o) (plus (plus o o) o)))))))\n (S (S (plus (plus (plus (plus o o) o) (plus (plus o o) o))\n (S (plus (plus (plus o o) o) (plus (plus o o) o))))))))))))))))))\n IsLimited14 : (o : Nat)\n -> Limited $ divSeq (S (S (S (S (S (plus (plus (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))\n (S (S (S (S (S (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o)))))))))\n (S (S (S (S (S (plus (plus (plus o o) (plus o o)) (plus (plus o o) (plus o o))))))))))))))\n -> Limited $ divSeq (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))))\n (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))))))))))))))\n (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o))))))))))\n (S (S (S (plus (plus (plus (plus o o) o) (S (plus (plus o o) o)))\n (S (S (plus (plus (plus o o) o) (S (plus (plus o o) o)))))))))))))))))))))))\n IsLimited15 : (o : Nat)\n -> Limited $ divSeq (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o)))\n (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o))))\n (plus (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o)))\n (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o)))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o)))\n (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o))))\n (plus (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o)))\n (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o)))))))))))))))))))))))))))))))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o)))\n (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o))))\n (plus (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o)))\n (plus (plus (plus o o)\n (plus o o))\n (plus (plus o o)\n (plus o o))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\n -> Limited $ divSeq (S (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))\n (S (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))))))))\n (S (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o)))))))))))))\n (S (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))\n (S (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o)\n (S (S (plus (plus o o) o)))))))))))))\n (S (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o)\n (S (S (plus (plus o o) o)))))))))))))))))))))\n (S (S (S (S (S (S (S (plus (plus (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))))))\n (S (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o)\n (S (S (plus (plus o o) o)))))))))))))\n (S (S (S (S (plus (plus (plus (plus o o) o) (S (S (plus (plus o o) o))))\n (S (S (S (plus (plus (plus o o) o)\n (S (S (plus (plus o o) o))))))))))))))))))))))))))))\n\nP : Nat -> Type\nP n = Limited $ divSeq (n+n+n)\ndefiniP : (n : Nat) -> P n = Limited $ divSeq (n+n+n)\ndefiniP n = Refl\n\n-- 無限降下法(の変形) Isabelleで証明した\npostulate infiniteDescent0 :\n ((n:Nat) -> (Not . P) (S n) -> (m ** (LTE (S m) (S n), (Not . P) m)))\n -> P Z\n -> P n\n-- ########################################\n\n\n\n-- from ProofColDivSeqMain\n-- ########################################\n-- ########################################\n\n\n\n-- from sub0xxxxx\n-- ########################################\n-- ########################################\n\n\n\n", "meta": {"hexsha": "12b02eca21d3b4f9fe24029b2a975bfb30960038", "size": 48935, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "program2/ProofColDivSeqPostulate.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": "program2/ProofColDivSeqPostulate.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": "program2/ProofColDivSeqPostulate.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": 113.275462963, "max_line_length": 227, "alphanum_fraction": 0.2174312864, "num_tokens": 9501, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9086178919837705, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.5788175776095124}}
{"text": "module Rhone.Canvas.Transformation\n\nimport JS\nimport Rhone.Canvas.Angle\nimport Web.Html\n\n--------------------------------------------------------------------------------\n-- Transformation\n--------------------------------------------------------------------------------\n\npublic export\ndata Transformation : Type where\n Id : Transformation\n Transform : (a,b,c,d,e,f : Double) -> Transformation\n\nexport\nscale : (h,w : Double) -> Transformation\nscale h w = Transform h 0 0 w 0 0\n\nexport\nrotate : Angle -> Transformation\nrotate phi =\n let r = toRadians phi\n c = cos r\n s = sin r\n in Transform c s (-s) c 0 0\n\nexport\ntranslate : (dx,dy : Double) -> Transformation\ntranslate dx dy = Transform 0 0 0 0 dx dy\n\nexport\nmult : Transformation -> Transformation -> Transformation\nmult Id x = x\nmult x Id = x\nmult (Transform a1 b1 c1 d1 e1 f1) (Transform a2 b2 c2 d2 e2 f2) =\n Transform (a1 * a2 + c1 * b2)\n (b1 * a2 + d1 * b2)\n (a1 * c2 + c1 * d2)\n (b1 * c2 + d1 * d2)\n (a1 * e2 + c1 * f2 + e1)\n (b1 * e2 + d1 * f2 + f1)\n\nexport %inline\nSemigroup Transformation where\n (<+>) = mult\n\nexport %inline\nMonoid Transformation where\n neutral = Id\n\n--------------------------------------------------------------------------------\n-- IO\n--------------------------------------------------------------------------------\n\nexport\napply : CanvasRenderingContext2D -> Transformation -> JSIO ()\napply ctxt Id = pure ()\napply ctxt (Transform a b c d e f) = setTransform ctxt a b c d e f\n", "meta": {"hexsha": "11ff7efe795076e116c7df00b5a8cf982b7187a5", "size": 1577, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Rhone/Canvas/Transformation.idr", "max_stars_repo_name": "mattpolzin/idris2-rhone-js", "max_stars_repo_head_hexsha": "8ddde9db0dbd20e4ac8fbf22da990fde96399c25", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2021-09-30T15:53:56.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-21T04:39:54.000Z", "max_issues_repo_path": "src/Rhone/Canvas/Transformation.idr", "max_issues_repo_name": "mattpolzin/idris2-rhone-js", "max_issues_repo_head_hexsha": "8ddde9db0dbd20e4ac8fbf22da990fde96399c25", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2021-11-04T04:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-09T03:42:48.000Z", "max_forks_repo_path": "src/Rhone/Canvas/Transformation.idr", "max_forks_repo_name": "mattpolzin/idris2-rhone-js", "max_forks_repo_head_hexsha": "8ddde9db0dbd20e4ac8fbf22da990fde96399c25", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-27T01:22:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-27T01:22:26.000Z", "avg_line_length": 26.2833333333, "max_line_length": 80, "alphanum_fraction": 0.4857324033, "num_tokens": 391, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9032942145139149, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.5786826612870561}}
{"text": "module Main\nimport Data.List\n\nmyTriple : Double -> Double\nmyTriple x = 3 * x\n\nmyDoublePow : Double -> Double\nmyDoublePow x = (pow) x 2\n\nmain : IO ()\nmain = do printLn $ (myDoublePow . myTriple) 5\n", "meta": {"hexsha": "0a971ac08676c21846307afe9cec262c02bb2837", "size": 196, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "8_func_composition.idr", "max_stars_repo_name": "jeetu7/idris2_examples", "max_stars_repo_head_hexsha": "b96be6fbb2db2f3ac89109f5c78b1881849a3910", "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": "8_func_composition.idr", "max_issues_repo_name": "jeetu7/idris2_examples", "max_issues_repo_head_hexsha": "b96be6fbb2db2f3ac89109f5c78b1881849a3910", "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": "8_func_composition.idr", "max_forks_repo_name": "jeetu7/idris2_examples", "max_forks_repo_head_hexsha": "b96be6fbb2db2f3ac89109f5c78b1881849a3910", "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.3333333333, "max_line_length": 46, "alphanum_fraction": 0.6836734694, "num_tokens": 64, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152325073083131, "lm_q2_score": 0.7090191337850933, "lm_q1q2_score": 0.5780154461651899}}
{"text": "module Sub05LTE216t225\n\nimport ProofColDivSeqBase\nimport ProofColDivSeqPostulate\n\n%default total\n\n\n-- 6(36t+37)+3 --FE[5,0,-4]--> 6(8t+7)+3\nexport\nlte216t225 : (m : Nat) -> LTE (S (S (S (S (S (S (S (S (m+m+m+m)+(m+m+m+m)))))))))\n (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)))))))))\nlte216t225 Z = (lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc) LTEZero\nlte216t225 (S m) =\n let lemma = lte216t225 m in\n\n rewrite (sym (plusSuccRightSucc m m)) in\n\n rewrite (sym (plusSuccRightSucc (plus m m) m)) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus m m) m) m)) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) m)\n (S (S (S (plus (plus (plus m m) m) m)))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) m)\n (S (S (plus (plus (plus m m) m) m))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) m)\n (S (plus (plus (plus m m) m) m)))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) m)\n (plus (plus (plus m m) m) m))) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus m m) m) (S (S (S (S (plus (plus m m) m))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus m m) m) (S (S (S (plus (plus m m) m)))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus m m) m) (S (S (plus (plus m m) m))))) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (S (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m)))))))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m))))))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m)))))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m))))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))\n (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m)))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))\n (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))\n (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m)))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))\n (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))\n (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m)))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))\n (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))\n (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m)))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m) (S (S (plus (plus m m) m)))))))))\n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m))))))))))))))) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))))))) \n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m)))) \n (S (S (S (S (plus (plus (plus m m) m) \n (S (S (plus (plus m m) \n m))))))))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m)))))))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))))))) \n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m)))) \n (S (S (S (S (plus (plus (plus m m) m) \n (S (S (plus (plus m m) \n m))))))))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m))))))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))))))) \n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m)))) \n (S (S (S (S (plus (plus (plus m m) m) \n (S (S (plus (plus m m) \n m))))))))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m)))))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m)))))))))\n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m))))))))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m))))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))))))) \n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m)))) \n (S (S (S (S (plus (plus (plus m m) m) \n (S (S (plus (plus m m) \n m))))))))))))))\n (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m)))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))))))) \n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m)))) \n (S (S (S (S (plus (plus (plus m m) m) \n (S (S (plus (plus m m) \n m))))))))))))))\n (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))))))) \n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m)))) \n (S (S (S (S (plus (plus (plus m m) m) \n (S (S (plus (plus m m) \n m))))))))))))))\n (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m)))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))))))) \n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m)))) \n (S (S (S (S (plus (plus (plus m m) m) \n (S (S (plus (plus m m) \n m))))))))))))))\n (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))))))) \n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m)))) \n (S (S (S (S (plus (plus (plus m m) m) \n (S (S (plus (plus m m) \n m))))))))))))))\n (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m)))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))))))) \n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m)))) \n (S (S (S (S (plus (plus (plus m m) m) \n (S (S (plus (plus m m) \n m))))))))))))))\n (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))))))) \n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m)))) \n (S (S (S (S (plus (plus (plus m m) m) \n (S (S (plus (plus m m) \n m))))))))))))))\n (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m)))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))))))) \n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m)))) \n (S (S (S (S (plus (plus (plus m m) m) \n (S (S (plus (plus m m) \n m))))))))))))))\n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (S (plus (plus m m) m))))\n (S (S (S (S (plus (plus (plus m m) m)\n (S (S (plus (plus m m)\n m))))))))))))))) in\n\n (lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc) lemma\n\n\n\n", "meta": {"hexsha": "68573d66a601f2b83abef9cd42c41414e29cb644", "size": 23977, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "program3/Sub05LTE216t225.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/Sub05LTE216t225.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/Sub05LTE216t225.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": 78.1009771987, "max_line_length": 541, "alphanum_fraction": 0.2917796221, "num_tokens": 6328, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278695464501, "lm_q2_score": 0.6548947290421276, "lm_q1q2_score": 0.5778973605258444}}
{"text": "module ProofColDivSeqBase\n\n%default total\n%access export\n\n\n-- ----- from libs/contrib/Data/CoList.idr -----\npublic export\ncodata CoList : Type -> Type where\n Nil : CoList a\n (::) : a -> CoList a -> CoList a\n\nimplementation Functor CoList where\n map f [] = []\n map f (x :: xs) = f x :: map f xs\n\nimplementation Show a => Show (CoList a) where\n show xs = \"[\" ++ show' \"\" 20 xs ++ \"]\" where\n show' : String -> (n : Nat) -> (xs : CoList a) -> String\n show' acc Z _ = acc ++ \"...\"\n show' acc (S n) [] = acc\n show' acc (S n) [x] = acc ++ show x\n show' acc (S n) (x :: xs) = show' (acc ++ (show x) ++ \", \") n xs\n\nunfoldr : (a -> Maybe (b, a)) -> a -> CoList b\nunfoldr f x =\n case f x of\n Just (y, new_x) => y :: (unfoldr f new_x)\n _ => []\n-- ----- from libs/contrib/Data/CoList.idr -----\n\n\n-- ----- from libs/contrib/Data/Nat/DivMod/IteratedSubtraction.idr -----\npublic export\ndata LT' : (n, m : Nat) -> Type where\n ||| n < 1 + n\n LTSucc : LT' n (S n)\n ||| n < m implies that n < m + 1\n LTStep : LT' n m -> LT' n (S m)\n\n||| Nothing is strictly less than zero\nimplementation Uninhabited (LT' n 0) where\n uninhabited LTSucc impossible\n\n||| Zero is less than any non-zero number.\nLTZeroLeast : LT' Z (S n)\nLTZeroLeast {n = Z} = LTSucc\nLTZeroLeast {n = S n} = LTStep LTZeroLeast\n\n||| If n < m, then 1 + n < 1 + m\nltSuccSucc : LT' n m -> LT' (S n) (S m)\nltSuccSucc LTSucc = LTSucc\nltSuccSucc (LTStep lt) = LTStep $ ltSuccSucc lt\n\n||| If n + 1 < m, then n < m\nlteToLt' : LTE (S n) m -> LT' n m\nlteToLt' {n = Z} (LTESucc x) = LTZeroLeast\nlteToLt' {n = S k} (LTESucc x) = ltSuccSucc $ lteToLt' x\n\nimplementation WellFounded LT' where\n wellFounded x = Access (acc x)\n where\n ||| Show accessibility by induction on the structure of the LT' witness\n acc : (x, y : Nat) -> LT' y x -> Accessible LT' y\n -- Zero is vacuously accessible: there's nothing smaller to check\n acc Z y lt = absurd lt\n -- If the element being accessed is one smaller, we're done\n acc (S y) y LTSucc = Access (acc y)\n -- If the element is more than one smaller, we need to go further\n acc (S k) y (LTStep smaller) = acc k y smaller\n-- ----- from libs/contrib/Data/Nat/DivMod/IteratedSubtraction.idr -----\n\n\n-- ---------------------------------\n-- mod2\npublic export\ndata Parity : Nat -> Type where\n Even : Parity (n + n)\n Odd : Parity (S (n + n))\nhelpEven : (j : Nat) -> Parity (S j + S j) -> Parity (S (S (plus j j)))\nhelpEven j p = rewrite plusSuccRightSucc j j in p\nhelpOdd : (j : Nat) -> Parity (S (S (j + S j))) -> Parity (S (S (S (j + j))))\nhelpOdd j p = rewrite plusSuccRightSucc j j in p\nparity : (n : Nat) -> Parity n\nparity Z = Even {n=Z}\nparity (S Z) = Odd {n=Z}\nparity (S (S k)) with (parity k)\n parity (S (S (j + j))) | Even = helpEven j (Even {n = S j})\n parity (S (S (S (j + j)))) | Odd = helpOdd j (Odd {n = S j})\n\n-- mod3\npublic export\ndata Mod3 : Nat -> Type where\n ThreeZero : Mod3 (n + n + n)\n ThreeOne : Mod3 (S (n + n + n))\n ThreeTwo : Mod3 (S (S (n + n + n)))\nhelpThreeZero : (j : Nat) -> (plus (plus (S j) (S j)) (S j)) = S (S (S (plus (plus j j) j)))\nhelpThreeZero j = rewrite sym $ plusSuccRightSucc j j in\n rewrite sym $ plusSuccRightSucc (plus j j) j in Refl\nhelpThreeOne : (j : Nat) -> S (plus (plus (S j) (S j)) (S j)) = S (S (S (S (plus (plus j j) j))))\nhelpThreeOne j = cong {f=S} $ helpThreeZero j\nhelpThreeTwo : (j : Nat) -> S (S (plus (plus (S j) (S j)) (S j))) = S (S (S (S (S (plus (plus j j) j)))))\nhelpThreeTwo j = cong {f=S} $ helpThreeOne j\nmod3 : (n : Nat) -> Mod3 n\nmod3 Z = ThreeZero {n=Z}\nmod3 (S Z) = ThreeOne {n=Z}\nmod3 (S (S Z)) = ThreeTwo {n=Z}\nmod3 (S (S (S k))) with (mod3 k)\n mod3 (S (S (S (j + j + j)))) | ThreeZero =\n rewrite sym $ helpThreeZero j in ThreeZero {n=S j}\n mod3 (S (S (S (S (j + j + j))))) | ThreeOne =\n rewrite sym $ helpThreeOne j in ThreeOne {n=S j}\n mod3 (S (S (S (S (S (j + j + j)))))) | ThreeTwo =\n rewrite sym $ helpThreeTwo j in ThreeTwo {n=S j}\n-- ---------------------------------\n\n\n-- ---------------------------------\ndsp : List Integer -> CoList Integer -> CoList Integer\ndsp _ [] = []\ndsp [] (y :: ys) = y :: ys\ndsp (x :: []) (y :: ys) = y :: ys\ndsp (x1 :: x2 :: []) (y :: ys) = x1 :: (x2 + y) :: ys\ndsp (x1 :: x2 :: x3 :: _) (y :: ys) = x1 :: x2 :: (x3 + y) :: ys\n\ncountEven : Nat -> Nat -> Nat -> (Nat, Nat)\ncountEven n Z acc = (acc, n)\ncountEven n (S nn) acc =\n if (modNatNZ n 2 SIsNotZ) == 1\n then (acc, n)\n else countEven (divNatNZ n 2 SIsNotZ) nn (acc+1)\n\n-- divSeqの実装\ndivSeq : Nat -> CoList Integer\ndivSeq n = divSeq' (S (S (S (n+n+n+n+n+n)))) (S (S (S (n+n+n+n+n+n)))) where\n divSeq' : Nat -> Nat -> CoList Integer\n divSeq' n Z = []\n divSeq' Z (S k) = []\n divSeq' (S n) (S k) with (parity n)\n divSeq' (S (S (j + j))) (S k) | Odd = divSeq' (S j) k --実際はここへは来ない\n divSeq' (S (j + j)) (S k) | Even =\n map toIntegerNat\n (unfoldr (\\b => if b <= 1 then Nothing\n else Just (countEven (b*3+1) (b*3+1) 0) ) (S (j + j)))\n\n{-\n72t+45 E[2,-4] y=x/12-3/4 6t+3 12x+7\n*8. <---------------------\n108t+99=6(18t+16)+3 EF[2,1,-2] y=2x/9-1 24t+21=6(4t+3)+3 4x+4+2t\n*6.\n108t+27=6(18t+4)+3 CF[4,1,-2] y=8x/9-3 96t+21=6(16t+3)+3 x+1+2t\n*5.\n216t+225=6(36t+37)+3 FE[5,0,-4] y=2x/9-5 48t+45=6(8t+7)+3 4x+9+4t\n*14.\n108t+111=6(18t+18)+3 FB[5,-1,-2] y=4x/9-13/3 48t+45=6(8t+7)+3 2x+11+2t\n\n0\n1+w\n 1+2v\n 1+2(2u) 2. 9. 11. 4. 13.\n 1+2(1+2u)\n 3+4(2t)\n 3+8(2s) 2. 9. 11. 8. 6.\n 3+8(1+2s) 2. 9. 11. 8.\n 3+4(1+2t) 2. 9. 11. 5. 14.\n 1+1+2v\n 1+1+2(2u) 2. 9. 11. 3. 12.\n 1+1+2(1+2u)\n 4+4(2t) 2. 9. 11. 3. 12. 7.\n 4+4(1+2t) 2. 9. 11. 3. 12.\n-}\n-- この部分の実装は、コンストラクタIsFirstLimited01~14の正当性を補強している\nallDivSeq : Nat -> List (CoList Integer)\nallDivSeq Z = [[1, 4], [2, -4] `dsp` [3,2,3,4], [3, 0, -4] `dsp` [2,3,1,1,5,4], [4, -4] `dsp` [1,1,1,5,4], [1, -2] `dsp` [6], [3, -1, -2] `dsp` [1,1,2,1,4,1,3,1,2,3,4]] -- 6*<0>+3 = 3\nallDivSeq (S w) with (parity w)\n allDivSeq (S (v + v)) | Even with (parity v)\n allDivSeq (S ((u + u) + (u + u))) | Even | Even\n = let x = (S ((u + u) + (u + u)))\n in [divSeq x, [2, -4] `dsp` divSeq (12*x+7), [4, -4] `dsp` divSeq (3*x+2), [1, -2] `dsp` divSeq (6*x+3), [6, -2, -4] `dsp` divSeq (9*x+16), [6, -3, -2] `dsp` divSeq (4*x+2*u+8)]\n allDivSeq (S ((S (u + u)) + (S (u + u)))) | Even | Odd with (parity u)\n allDivSeq (S ((S ((t + t) + (t + t))) + (S ((t + t) + (t + t))))) | Even | Odd | Even with (parity t)\n allDivSeq (S ((S (((s + s) + (s + s)) + ((s + s) + (s + s)))) + (S (((s + s) + (s + s)) + ((s + s) + (s + s)))))) | Even | Odd | Even | Even\n = let x = (S ((S (((s + s) + (s + s)) + ((s + s) + (s + s)))) + (S (((s + s) + (s + s)) + ((s + s) + (s + s))))))\n in [divSeq x, [2, -4] `dsp` divSeq (12*x+7), [4, -4] `dsp` divSeq (3*x+2), [1, -2] `dsp` divSeq (6*x+3), [2, 1, -2] `dsp` divSeq (4*x+8*s+4), [4, 1, -2] `dsp` divSeq (x+2*s+1)]\n allDivSeq (S ((S (((S (s + s)) + (S (s + s))) + ((S (s + s)) + (S (s + s))))) + (S (((S (s + s)) + (S (s + s))) + ((S (s + s)) + (S (s + s))))))) | Even | Odd | Even | Odd\n = let x = (S ((S (((S (s + s)) + (S (s + s))) + ((S (s + s)) + (S (s + s))))) + (S (((S (s + s)) + (S (s + s))) + ((S (s + s)) + (S (s + s)))))))\n in [divSeq x, [2, -4] `dsp` divSeq (12*x+7), [4, -4] `dsp` divSeq (3*x+2), [1, -2] `dsp` divSeq (6*x+3), [2, 1, -2] `dsp` divSeq (4*x+8*s+4)]\n allDivSeq (S ((S ((S (t + t)) + (S (t + t)))) + (S ((S (t + t)) + (S (t + t)))))) | Even | Odd | Odd\n = let x = (S ((S ((S (t + t)) + (S (t + t)))) + (S ((S (t + t)) + (S (t + t))))))\n in [divSeq x, [2, -4] `dsp` divSeq (12*x+7), [4, -4] `dsp` divSeq (3*x+2), [1, -2] `dsp` divSeq (6*x+3), [5, 0, -4] `dsp` divSeq (4*x+4*t+9), [5, -1, -2] `dsp` divSeq (2*x+2*t+11)]\n allDivSeq (S (S (v + v))) | Odd with (parity v)\n allDivSeq (S (S ((u + u) + (u + u)))) | Odd | Even\n = let x = (S (S ((u + u) + (u + u))))\n in [divSeq x, [2, -4] `dsp` divSeq (12*x+7), [4, -4] `dsp` divSeq (3*x+2), [1, -2] `dsp` divSeq (6*x+3), [3, 0, -4] `dsp` divSeq (18*x+13), [3, -1, -2] `dsp` divSeq (9*x+6)]\n allDivSeq (S (S ((S (u + u)) + (S (u + u))))) | Odd | Odd with (parity u)\n allDivSeq (S (S ((S ((t + t) + (t + t))) + (S ((t + t) + (t + t)))))) | Odd | Odd | Even\n = let x = (S (S ((S ((t + t) + (t + t))) + (S ((t + t) + (t + t))))))\n in [divSeq x, [2, -4] `dsp` divSeq (12*x+7), [4, -4] `dsp` divSeq (3*x+2), [1, -2] `dsp` divSeq (6*x+3), [3, 0, -4] `dsp` divSeq (18*x+13), [3, -1, -2] `dsp` divSeq (9*x+6), [1, 3, -2] `dsp` divSeq (2*x+2*t+2)]\n allDivSeq (S (S ((S ((S (t + t)) + (S (t + t)))) + (S ((S (t + t)) + (S (t + t))))))) | Odd | Odd | Odd\n = let x = (S (S ((S ((S (t + t)) + (S (t + t)))) + (S ((S (t + t)) + (S (t + t)))))))\n in [divSeq x, [2, -4] `dsp` divSeq (12*x+7), [4, -4] `dsp` divSeq (3*x+2), [1, -2] `dsp` divSeq (6*x+3), [3, 0, -4] `dsp` divSeq (18*x+13), [3, -1, -2] `dsp` divSeq (9*x+6)]\n-- ---------------------------------\n\n\n-- ---------------------------------\nmutual\n public export\n data FirstLimited : List (CoList Integer) -> Type where\n IsFirstLimited01 : (FirstLimited . ProofColDivSeqBase.allDivSeq) 1 -- 6*<1>+3 = 9\n IsFirstLimited02 : (l : Nat)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) l\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (S (((S (l+l))+(S (l+l))) + ((S (l+l))+(S (l+l))) + ((S (l+l))+(S (l+l)))))\n IsFirstLimited03 : (m : Nat)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (m+m)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (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)))))))\n IsFirstLimited04 : (m : Nat)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (S ((m+m)+(m+m)))\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (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))))))))\n IsFirstLimited05 : (m : Nat)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (S (S (S (S (S (S (S (m+m+m+m)+(m+m+m+m))))))))\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (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)))))))))\n IsFirstLimited06 : (l : Nat)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (S (S (S (l+l+l+l)+(l+l+l+l)+(l+l+l+l)+(l+l+l+l))))\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (S ((S ((l+l+l)+(l+l+l))) + (S ((l+l+l)+(l+l+l))) + (S ((l+l+l)+(l+l+l)))))\n IsFirstLimited07 : (l : Nat)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (S (S (S (S (l+l+l+l)+(l+l+l+l)))))\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (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))))))\n IsFirstLimited08 : (l : Nat)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (S (S (S ((l+l)+(l+l)))))\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (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)))))))\n IsFirstLimited09 : (j : Nat)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) j\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (S (S (plus (plus j j) j)))\n IsFirstLimited10 : (FirstLimited . ProofColDivSeqBase.allDivSeq) 0 -- 6*<0>+3 = 3\n IsFirstLimited11 : (k : Nat)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) k\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (S (S (S ( (k+k) + (k+k) + (k+k)))))\n IsFirstLimited12 : (l : Nat)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (l+l)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (S (S (S ((S ((l+l+l)+(l+l+l))) + (S ((l+l+l)+(l+l+l))) + (S ((l+l+l)+(l+l+l)))))))\n IsFirstLimited13 : (l : Nat)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (S ((l+l)+(l+l)))\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (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))))))))\n IsFirstLimited14 : (l : Nat)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (S (S (S (S (S (S (S (l+l+l+l)+(l+l+l+l))))))))\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (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)))))))))\n\n IsFirstLimitedSuff2_1 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (1 + 2 * (2 * z))\n IsFirstLimitedSuff2_2 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (12 * (1 + 2 * (2 * z)) + 7)\n IsFirstLimitedSuff2_3 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 * (1 + 2 * (2 * z)) + 2)\n IsFirstLimitedSuff2_4 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (6 * (1 + 2 * (2 * z)) + 3)\n IsFirstLimitedSuff2_5 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (9 * (1 + 2 * (2 * z)) + 16)\n IsFirstLimitedSuff2_6 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (4 * (1 + 2 * (2 * z)) + 2 * z + 8)\n\n IsFirstLimitedSuff3_1 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 + 8 * (2 * z))\n IsFirstLimitedSuff3_2 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (12 * (3 + 8 * (2 * z)) + 7)\n IsFirstLimitedSuff3_3 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 * (3 + 8 * (2 * z)) + 2)\n IsFirstLimitedSuff3_4 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (6 * (3 + 8 * (2 * z)) + 3)\n IsFirstLimitedSuff3_5 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (4 * (3 + 8 * (2 * z)) + 8 * z + 4)\n IsFirstLimitedSuff3_6 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) ((3 + 8 * (2 * z)) + 2 * z + 1)\n\n IsFirstLimitedSuff4_1 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 + 8 * (1 + 2 * z))\n IsFirstLimitedSuff4_2 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (12 * (3 + 8 * (1 + 2 * z)) + 7)\n IsFirstLimitedSuff4_3 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 * (3 + 8 * (1 + 2 * z)) + 2)\n IsFirstLimitedSuff4_4 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (6 * (3 + 8 * (1 + 2 * z)) + 3)\n IsFirstLimitedSuff4_5 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (4 * (3 + 8 * (1 + 2 * z)) + 8 * z + 4)\n\n IsFirstLimitedSuff5_1 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 + 4 * (1 + 2 * z))\n IsFirstLimitedSuff5_2 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (12 * (3 + 4 * (1 + 2 * z)) + 7)\n IsFirstLimitedSuff5_3 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 * (3 + 4 * (1 + 2 * z)) + 2)\n IsFirstLimitedSuff5_4 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (6 * (3 + 4 * (1 + 2 * z)) + 3)\n IsFirstLimitedSuff5_5 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (4 * (3 + 4 * (1 + 2 * z)) + 4 * z + 9)\n IsFirstLimitedSuff5_6 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (2 * (3 + 4 * (1 + 2 * z)) + 2 * z + 11)\n\n IsFirstLimitedSuff6_1 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (1 + 1 + 2 * (2 * z))\n IsFirstLimitedSuff6_2 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (12 * (1 + 1 + 2 * (2 * z)) + 7)\n IsFirstLimitedSuff6_3 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 * (1 + 1 + 2 * (2 * z)) + 2)\n IsFirstLimitedSuff6_4 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (6 * (1 + 1 + 2 * (2 * z)) + 3)\n IsFirstLimitedSuff6_5 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (18 * (1 + 1 + 2 * (2 * z)) + 13)\n IsFirstLimitedSuff6_6 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (9 * (1 + 1 + 2 * (2 * z)) + 6)\n\n IsFirstLimitedSuff7_1 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (4 + 4 * (2 * z))\n IsFirstLimitedSuff7_2 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (12 * (4 + 4 * (2 * z)) + 7)\n IsFirstLimitedSuff7_3 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 * (4 + 4 * (2 * z)) + 2)\n IsFirstLimitedSuff7_4 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (6 * (4 + 4 * (2 * z)) + 3)\n IsFirstLimitedSuff7_5 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (18 * (4 + 4 * (2 * z)) + 13)\n IsFirstLimitedSuff7_6 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (9 * (4 + 4 * (2 * z)) + 6)\n IsFirstLimitedSuff7_7 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (2 * (4 + 4 * (2 * z)) + 2 * z + 2)\n\n IsFirstLimitedSuff8_1 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (4 + 4 * (1 + 2 * z))\n IsFirstLimitedSuff8_2 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (12 * (4 + 4 * (1 + 2 * z)) + 7)\n IsFirstLimitedSuff8_3 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 * (4 + 4 * (1 + 2 * z)) + 2)\n IsFirstLimitedSuff8_4 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (6 * (4 + 4 * (1 + 2 * z)) + 3)\n IsFirstLimitedSuff8_5 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (18 * (4 + 4 * (1 + 2 * z)) + 13)\n IsFirstLimitedSuff8_6 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) z\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (9 * (4 + 4 * (1 + 2 * z)) + 6)\n\n public export\n data AllLimited : List (CoList Integer) -> Type where\n IsAllLimited00 : (AllLimited . ProofColDivSeqBase.allDivSeq) Z -- 6*<0>+3 = 3\n IsAllLimited01 : (z : Nat)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) Z\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (1 + 2 * (2 * z))\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (3 + 8 * (2 * z))\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (3 + 8 * (1 + 2 * z))\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (3 + 4 * (1 + 2 * z))\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (1 + 1 + 2 * (2 * z))\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (4 + 4 * (2 * z))\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (4 + 4 * (1 + 2 * z))\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) z\n IsAllLimited02 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (1 + 2 * (2 * z))\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (12 * (1 + 2 * (2 * z)) + 7)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 * (1 + 2 * (2 * z)) + 2)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (6 * (1 + 2 * (2 * z)) + 3)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (9 * (1 + 2 * (2 * z)) + 16)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (4 * (1 + 2 * (2 * z)) + 2 * z + 8)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (1 + 2 * (2 * z))\n IsAllLimited03 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 + 8 * (2 * z))\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (12 * (3 + 8 * (2 * z)) + 7)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 * (3 + 8 * (2 * z)) + 2)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (6 * (3 + 8 * (2 * z)) + 3)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (4 * (3 + 8 * (2 * z)) + 8 * z + 4)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) ((3 + 8 * (2 * z)) + 2 * z + 1)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (3 + 8 * (2 * z))\n IsAllLimited04 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 + 8 * (1 + 2 * z))\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (12 * (3 + 8 * (1 + 2 * z)) + 7)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 * (3 + 8 * (1 + 2 * z)) + 2)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (6 * (3 + 8 * (1 + 2 * z)) + 3)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (4 * (3 + 8 * (1 + 2 * z)) + 8 * z + 4)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (3 + 8 * (1 + 2 * z))\n IsAllLimited05 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 + 4 * (1 + 2 * z))\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (12 * (3 + 4 * (1 + 2 * z)) + 7)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 * (3 + 4 * (1 + 2 * z)) + 2)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (6 * (3 + 4 * (1 + 2 * z)) + 3)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (4 * (3 + 4 * (1 + 2 * z)) + 4 * z + 9)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (2 * (3 + 4 * (1 + 2 * z)) + 2 * z + 11)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (3 + 4 * (1 + 2 * z))\n IsAllLimited06 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (1 + 1 + 2 * (2 * z))\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (12 * (1 + 1 + 2 * (2 * z)) + 7)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 * (1 + 1 + 2 * (2 * z)) + 2)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (6 * (1 + 1 + 2 * (2 * z)) + 3)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (18 * (1 + 1 + 2 * (2 * z)) + 13)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (9 * (1 + 1 + 2 * (2 * z)) + 6)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (1 + 1 + 2 * (2 * z))\n IsAllLimited07 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (4 + 4 * (2 * z))\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (12 * (4 + 4 * (2 * z)) + 7)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 * (4 + 4 * (2 * z)) + 2)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (6 * (4 + 4 * (2 * z)) + 3)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (18 * (4 + 4 * (2 * z)) + 13)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (9 * (4 + 4 * (2 * z)) + 6)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (2 * (4 + 4 * (2 * z)) + 2 * z + 2)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (4 + 4 * (2 * z))\n IsAllLimited08 : (z : Nat)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (4 + 4 * (1 + 2 * z))\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (12 * (4 + 4 * (1 + 2 * z)) + 7)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (3 * (4 + 4 * (1 + 2 * z)) + 2)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (6 * (4 + 4 * (1 + 2 * z)) + 3)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (18 * (4 + 4 * (1 + 2 * z)) + 13)\n -> (FirstLimited . ProofColDivSeqBase.allDivSeq) (9 * (4 + 4 * (1 + 2 * z)) + 6)\n -> (AllLimited . ProofColDivSeqBase.allDivSeq) (4 + 4 * (1 + 2 * z))\n --Uninhabited (AllLimited xs) where --使わなかった\n -- uninhabited a impossible\n --allToVoid : (x : Nat) -> Not $ AllLimited (allDivSeq (S x))\n --allToVoid x prf impossible\n-- ---------------------------------\n\n\n\n", "meta": {"hexsha": "5d05d30ac3c4600702a73f619bd77639697706d0", "size": 26563, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "program3/ProofColDivSeqBase.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/ProofColDivSeqBase.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/ProofColDivSeqBase.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": 57.9978165939, "max_line_length": 324, "alphanum_fraction": 0.5176373151, "num_tokens": 10455, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.822189121808099, "lm_q2_score": 0.7025300698514778, "lm_q1q2_score": 0.5776125811749689}}
{"text": "||| Additional properties/lemmata of Nats involving order\nmodule Data.Nat.Order.Properties\n\nimport Syntax.PreorderReasoning\nimport Syntax.PreorderReasoning.Generic\nimport Data.Nat\nimport Data.Nat.Order\nimport Data.Nat.Order.Strict\nimport Decidable.Equality\nimport Decidable.Order.Strict\nimport Data.Bool.Decidable\n\n\n%default total\nexport\nLTESuccInjectiveMonotone : (m, n : Nat) -> Reflects (m `LTE` n) b -> Reflects (S m `LTE` S n) b\nLTESuccInjectiveMonotone m n (RTrue m_lte_n) = RTrue $ LTESucc m_lte_n\nLTESuccInjectiveMonotone m n (RFalse not_m_lte_n) = RFalse $ \\case\n LTESucc m_lte_n => not_m_lte_n m_lte_n\n\nexport\nlteReflection : (a, b : Nat) -> Reflects (a `LTE` b) (a `lte` b)\nlteReflection 0 b = RTrue LTEZero\nlteReflection (S k) 0 = RFalse $ \\sk_lte_z => absurd sk_lte_z\nlteReflection (S a) (S b) = LTESuccInjectiveMonotone a b (lteReflection a b)\n\nexport\nltReflection : (a, b : Nat) -> Reflects (a `LT` b) (a `lt` b)\nltReflection a = lteReflection (S a)\n\n-- For example:\nexport\nlteIsLTE : (a, b : Nat) -> a `lte` b = True -> a `LTE` b\nlteIsLTE a b prf = invert (replace {p = Reflects (a `LTE` b)} prf (lteReflection a b))\n\nexport\nltIsLT : (a, b : Nat) -> a `lt` b = True -> a `LT` b\nltIsLT a = lteIsLTE (S a)\n\nexport\nnotlteIsNotLTE : (a, b : Nat) -> a `lte` b = False -> Not (a `LTE` b)\nnotlteIsNotLTE a b prf = invert (replace {p = Reflects (a `LTE` b)} prf (lteReflection a b))\n\nexport\nnotltIsNotLT : (a, b : Nat) -> a `lt` b = False -> Not (a `LT` b)\nnotltIsNotLT a = notlteIsNotLTE (S a)\n\n\nexport\nnotlteIsLT : (a, b : Nat) -> a `lte` b = False -> b `LT` a\nnotlteIsLT a b prf = notLTImpliesGTE $\n \\prf' =>\n (invert $ replace {p = Reflects (S a `LTE` S b)} prf\n $ lteReflection (S a) (S b)) prf'\n\nexport\nnotltIsGTE : (a, b : Nat) -> (a `lt` b) === False -> a `GTE` b\nnotltIsGTE a b p = notLTImpliesGTE (notlteIsNotLTE (S a) b p)\n\n\n-- The converse to lteIsLTE:\nexport\nLteIslte : (a, b : Nat) -> a `LTE` b -> a `lte` b = True\nLteIslte a b a_lt_b = reflect (lteReflection a b) a_lt_b\n\n-- The converse to lteIsLTE with negation\nexport\nnotLteIsnotlte : (a, b : Nat) -> Not (a `LTE` b) -> a `lte` b = False\nnotLteIsnotlte a b not_a_lte_b = reflect (lteReflection a b) not_a_lte_b\n\n-- The converse to lteIsLTE:\nexport\nGTIsnotlte : (a, b : Nat) -> b `LT` a -> a `lte` b = False\nGTIsnotlte a b prf =\n notLteIsnotlte a b $ \\contra =>\n succNotLTEpred $ transitive {rel = LTE} prf contra\n\n||| Subtracting a number gives a smaller number\nexport\nminusLTE : (a,b : Nat) -> (b `minus` a) `LTE` b\nminusLTE a 0 = LTEZero\nminusLTE 0 (S b) = reflexive {rel = LTE}\nminusLTE (S a) (S b) =\n transitive {rel = LTE}\n (minusLTE a b)\n (lteSuccRight (reflexive {rel = LTE}))\n\n||| Subtracting a positive number gives a strictly smaller number\nexport\nminusPosLT : (a,b : Nat) -> 0 `LT` a -> a `LTE` b -> (b `minus` a) `LT` b\nminusPosLT 0 b z_lt_z a_lte_b impossible\nminusPosLT (S a) 0 z_lt_sa a_lte_b impossible\nminusPosLT (S a) (S b) z_lt_sa a_lte_b = LTESucc (minusLTE a b)\n\n-- This is the opposite of the convention in `Data.Nat`, but 'monotone on the left' means the below\nexport\nmultLteMonotoneRight : (l, a, b : Nat) -> a `LTE` b -> l*a `LTE` l*b\nmultLteMonotoneRight 0 a b _ = LTEZero\nmultLteMonotoneRight (S k) a b a_lte_b = CalcWith {leq = LTE} $\n |~ (1 + k) * a\n ~~ a + k*a ...(Refl)\n <~ b + k*a ...(plusLteMonotoneRight (k*a) a b a_lte_b)\n <~ b + k*b ...(plusLteMonotoneLeft b (k*a) (k*b) $\n multLteMonotoneRight k a b a_lte_b)\n ~~ (1 + k) * b ...(Refl)\n\nexport\nmultLteMonotoneLeft : (a, b, r : Nat) -> a `LTE` b -> a*r `LTE` b*r\nmultLteMonotoneLeft a b r a_lt_b =\n rewrite multCommutative a r in\n rewrite multCommutative b r in\n multLteMonotoneRight r a b a_lt_b\n", "meta": {"hexsha": "6fe0f8449600ddad1d9553079535ed93a81a6e7c", "size": 3924, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/contrib/Data/Nat/Order/Properties.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/Order/Properties.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/Order/Properties.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": 34.7256637168, "max_line_length": 101, "alphanum_fraction": 0.624872579, "num_tokens": 1428, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059414036511, "lm_q2_score": 0.7279754371026367, "lm_q1q2_score": 0.5773616443620211}}
{"text": "module BTree\n\npublic export\ndata BTree a = Leaf\n | Node (BTree a) a (BTree a)\n\nexport\ninsert : Ord a => a -> BTree a -> BTree a\ninsert x Leaf = Node Leaf x Leaf\ninsert x (Node l v r) = if (x < v) then (Node (insert x l) v r)\n else (Node l v (insert x r))\n\nexport\ntoList : BTree a -> List a\ntoList Leaf = []\ntoList (Node l v r) = BTree.toList l ++ (v :: BTree.toList r)\n\nexport\ntoTree : Ord a => List a -> BTree a\ntoTree [] = Leaf\ntoTree (x :: xs) = insert x (toTree xs)\n", "meta": {"hexsha": "91e86e879db27217d47cce4411fe0a703ef3815b", "size": 516, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "samples/BTree.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": "samples/BTree.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": "samples/BTree.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": 23.4545454545, "max_line_length": 63, "alphanum_fraction": 0.5678294574, "num_tokens": 163, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.7799928951399098, "lm_q1q2_score": 0.577330743555148}}
{"text": "> module NonNegDouble.open_issues.Main\n\n> %default total\n> %access public export\n\n> data Positive : Nat -> Type where\n> MkPositive : {n : Nat} -> Positive (S n)\n\n> PNat : Type\n> PNat = Subset Nat Positive\n\n> Fraction : Type\n> Fraction = (Nat, PNat)\n\n> data Normal : Fraction -> Type\n\n> NonNegRational : Type\n> NonNegRational = Subset Fraction Normal\n\n> plus : NonNegRational -> NonNegRational -> NonNegRational\n\n> mult : NonNegRational -> NonNegRational -> NonNegRational\n\n> fromNat : (n : Nat) -> NonNegRational\n\n> implementation Num NonNegRational where\n> (+) = plus\n> (*) = mult\n> fromInteger = fromNat . fromIntegerNat\n", "meta": {"hexsha": "4eb988f203157b5cf2ebc2d0d3f25dd72152e333", "size": 632, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "NonNegDouble/issues/num_parameter_rational.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/issues/num_parameter_rational.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/issues/num_parameter_rational.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": 21.0666666667, "max_line_length": 59, "alphanum_fraction": 0.6867088608, "num_tokens": 185, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8902942348544447, "lm_q2_score": 0.6477982315512488, "lm_q1q2_score": 0.5767310308989815}}
{"text": "> module Main\n\n> import Syntax.PreorderReasoning\n> import Data.List\n> import Effects\n> import Effect.Exception\n> import Effect.StdIO\n\n> %default total\n> %access public export\n> %auto_implicits off\n\n* 1. An amazingly versatile functional \n\nThey start from the offset with |bigotimes|, the function to be\ndiscussed in the paper\n\n> bigotimes : {X, R : Type} -> List ((X -> R) -> X) -> (List X -> R) -> List X\n> bigotimes Nil p = Nil\n> bigotimes (e :: es) p = x0 :: bigotimes es (p . (x0 ::)) where\n> x0 = e (\\ x => p (x :: bigotimes es (p . (x ::))))\n\n, introduce the notion of selection function\n\n> Selection : Type -> Type -> Type \n> Selection X R = (X -> R) -> X\n\nand of a \"binary operation that combines two selection functions\" in\nterms of which |bigotimes| can be implemented recursively. In the rest\nof the section they relate |bigotimes| with sequential games (apparently\ndeterministic, with finite or infinite number of steps and alternating\nplayers), with the Tychonoff theorem and with the Double-Negation Shift\n(DNS). Then they present an outline of the paper.\n\n\n* 2. Selection functions\n\nThey start by introducing shortcuts for (flipped) selection functions\n\n> J : Type -> Type -> Type\n> J R X = (X -> R) -> X\n\nand generalized quantifiers \n\n> K : Type -> Type -> Type\n> K R X = (X -> R) -> R\n\nHere, |R| represents generalized truth values. The text suggests that\nselection functions of type |J R X| and quantifiers of type |K R X| take\nas arguments functions of type |X -> R| that represent properties of\nvalues of type |X|, see the \"Terminology\" table.\n\nAs a matter of fact, however, these functions are not dependently\ntyped. I think that the arguments of selection functions and quantifiers\nare in fact decision procedured associated for a decidable property of\ninterest. Thus, for instance, for |X = Nat| and |R = Bool|, one could\nhave\n\n> P : Nat -> Type\n> P i = LTE i 42\n\nand\n\n> dP : Nat -> Bool\n> dP i = if i <= 42 then True else False\n\nAnyway, the authors go on by remarking that, with the |J| operator, the\ntype of |bigotimes| can be rewritten as\n\n< bigotimes : {X, R : Type} -> List (J R X) -> J R (List X)\n\nThey then introduce\n\n> overline : {X, R : Type} -> J R X -> K R X\n> overline e = \\ p => p (e p)\n\nand start discussing selection functions for sets in a subsection. \n\n\n** 2.1 Selection functions for sets \n\nEscardo-Oliva start by stating that \"A selection function for a set S\nfinds an element of S for which a given predicate holds\". They require\nselection functions for sets to be total and point out that \"if there is\nno element of S satisfying the predicate, we select an arbitrary element\nof S\". Thus, selection functions for sets are only defined for non-empty\nsets\n\n> find : {X : Type} -> (xs : List X) -> NonEmpty xs -> J Bool X -- J Bool xs\n> find Nil _ p impossible\n> find (x :: xs) _ p with (nonEmpty xs)\n> | (Yes prf) = if p x then x else find xs prf p\n> | ( No prf) = x\n\n> forsome : {X : Type} -> (xs : List X) -> NonEmpty xs -> K Bool X\n> forsome xs ne = overline (find xs ne)\n\n> forevery : {X : Type} -> (xs : List X) -> NonEmpty xs -> K Bool X\n> forevery xs ne p = not (forsome xs ne (not . p))\n\nAt this point, Escardo-Oliva point out that their definition of the\nexistential quantifier is the same as in Hilbert’s ε-calculus: \n\n ∃x p(x) ⇐⇒ p(ε(p)).\n\nThis looks like a claim about |find|:\n\n> findLemma1 : {X : Type} -> \n> (xs : List X) -> (ne : NonEmpty xs) -> (p : X -> Bool) -> \n> (x ** p x = True) -> p (find xs ne p) = True\n\n> findLemma2 : {X : Type} -> \n> (xs : List X) -> (ne : NonEmpty xs) -> (p : X -> Bool) -> \n> p (find xs ne p) = True -> (x ** p x = True)\n\nThe second lemma holds trivially\n\n> findLemma2 {X} xs ne p prf = (find xs ne p ** prf) \n\nand it should not be difficult to show that the first one holds as well\nusing the implementation of |find|:\n\n> findLemma2 {X} Nil _ p prf impossible\n> findLemma2 {X} (x :: xs) _ p prf = ?lala\n\nFurther, they state that a selection function ε for a set S has to\nsatisfy:\n\n1. ε(p) ∈ S, whether or not there actually is some x ∈ S such that p(x)\n holds.\n\n2. If p(x) holds for some x ∈ S, then it holds for x = ε(p).\n\nWith the helper function\n\n> typeOf : {X : Type} -> X -> Type\n> typeOf {X} _ = X \n\nthe first condition boils down to\n\n> SpecJ1 : {X, R : Type} -> (eps : J R X) -> (p : X -> R) -> typeOf (eps p) = X\n\nwhich trivially holds\n\n> SpecJ1 eps p = Refl\n\nIn the second condition it is not completely clear what it means for\np(x) to \"hold\". If we restrict ourselves to the case in which |R =\nBool|, I think that the condition could be written as\n\n< SpecJ2 : {X : Type} -> (eps : J Bool X) -> (p : X -> Bool) -> (x : X) -> p x = True -> p (eps p) = True \n\nHere we have translated \"p(x) holds\" with |p x = True|. If the arguments\nof selection functions and quantifiers were truly propositions, we would\nagain know how to formalize condition 2\n\n< SpecJ2 : {X : Type} -> (eps : J Type X) -> (p : X -> Type) -> (x : X) -> p x -> p (eps p)\n\n\n** 2.2 Selection functions for quantifiers\n\nHilbert's condition\n\n ϕ p = p (ε p)\n\nis used to express what it means for a selection function to be\ncompatible with a quantifier:\n\n> infixl 9 <> \n\n> (<>) : {X, R : Type} -> (eps : J R X) -> (phi : K R X) -> Type\n> (<>) {X} {R} eps phi = (p : X -> R) -> phi p = p (eps p) \n\nThis trivially implies\n\n> overlineLemma : {X, R : Type} -> (eps : J R X) -> eps <> overline eps\n> overlineLemma eps = \\ p => Refl\n\nThen they give examples of selection functions that are compatible with\ngiven quantifiers. One for the universal quantifier\n\n< forevery : {X : Type} -> (xs : List X) -> NonEmpty xs -> K Bool X\n< forevery xs ne p = not (forsome xs ne (not . p))\n\nis |findnot|:\n\n> findnot : {X : Type} -> (xs : List X) -> NonEmpty xs -> J Bool X\n> findnot Nil _ p impossible\n> findnot (x :: xs) _ p with (nonEmpty xs)\n> | (Yes prf) = if p x then find xs prf p else x\n> | ( No prf) = x\n\nthey argue. They first notice that\n\n> findnotLemma : {X : Type} -> \n> (xs : List X) -> (ne : NonEmpty xs) ->\n> (p : X -> Bool) -> findnot xs ne p = find xs ne (not . p)\n\nand \n\n> foreveryFindnotLemma : {X : Type} -> \n> (xs : List X) -> (ne : NonEmpty xs) -> \n> (p : X -> Bool) -> \n> forevery xs ne p = overline (findnot xs ne) p\n\nfrom which they conclude\n\n> findnotForeveryLemma : {X : Type} -> \n> (xs : List X) -> (ne : NonEmpty xs) -> \n> findnot xs ne <> forevery xs ne\n> findnotForeveryLemma xs ne p = ( forevery xs ne p )\n> ={ foreveryFindnotLemma xs ne p }=\n> ( overline (findnot xs ne) p )\n> ={ overlineLemma (findnot xs ne) p }=\n> ( p (findnot xs ne p) )\n> QED\n\nFurther examples of selection functions are given for \"predicates\" that\nreturn numbers rather than Boolean values:\n\n> {-\n\n> argsup : {X : Type} -> (xs : List X) -> (ne : NonEmpty xs) -> J Int X\n> argsup Nil _ p impossible\n> argsup (x :: xs) _ p with (nonEmpty xs)\n> | (Yes prf) = if p x < p x' then x' else x \n> where x' = argsup xs prf p\n> | ( No prf) = x\n\n> arginf : {X : Type} -> (xs : List X) -> (ne : NonEmpty xs) -> J Int X\n> arginf xs ne p = argsup xs ne (\\ x => - p x)\n\n>-}\n\n-- > partial\n-- > argsup : {X : Type} -> List X -> J Int X -- here Int is just {-1, 0, 1}\n-- > -- argsup [] p = undefined\n-- > argsup {X} (x :: xs) p = f xs x (p x)\n-- > where\n-- > f : List X -> X -> Int -> X\n-- > f xs' a 1 = a\n-- > f [] a r = a\n-- > f xs' a 0 = g xs'\n-- > where\n-- > g [] = a\n-- > g (a :: as) = if p a == 1 then a else g as\n-- > f (x' :: xs') a r = f xs' x' (p x') -- at this point, r = -1\n \n-- > {- original implementation (non-optimised) -}\n-- > partial\n-- > argsup : {X : Type} -> (xs : List X) -> J Int X\n-- > argsup (x :: xs) p with (nonEmpty xs)\n-- > | (Yes prf) = if p x < p x' then x' else x \n-- > where x' = argsup xs p\n-- > | ( No prf) = x\n\n> partial\n> argsup : {X : Type} -> (xs : List X) -> J Int X\n> argsup (x :: Nil) p = x\n> argsup (x :: x' :: xs) p = if p x < p x' then argsup (x' :: xs) p else argsup (x :: xs) p\n\n\n-- > findnot xs prf p = find xs prf (not . p)\n\n\n> partial\n> arginf : {X : Type} -> (xs : List X) -> J Int X\n> arginf xs p = argsup xs (\\ x => - p x)\n\n\n* 3 Products of selection functions\n\n** 3.1 Binary product\n\n> opairJ : {X, Y, R : Type} -> J R X -> J R Y -> J R (X,Y)\n> opairJ epsx epsy p = (a, b) where\n> a = epsx (\\ x => overline epsy (\\ y => p (x, y)))\n> b = epsy (\\ y => p (a, y))\n\n> opairK : {X, Y, R : Type} -> K R X -> K R Y -> K R (X,Y)\n> opairK phix phiy p = phix (\\ x => phiy (\\ y => p (x, y)))\n\nIt is easy to see that |opairJ| implements two backwards induction steps\nfollowed by a forward computation of \"optimal\" controls:\n\n> opairJ' : {X, Y, R : Type} -> J R X -> J R Y -> J R (X,Y)\n> opairJ' {X} {Y} epsx epsy p = (x, y) where\n> piy : X -> Y\n> piy = \\ x => epsy (\\ y => p (x, y))\n> pix : Unit -> X\n> pix = \\ u => epsx (\\ x => p (x, piy x))\n> x : X\n> x = pix ()\n> y : Y\n> y = piy x\n\nIn this context, the set of states at decision steps one and two are\n|Unit| and |X|, respectively. The controls are |X| in the first step and\n|Y| in the second step.\n\nIn order to compute the result of |opairJ' epsx epsy p|, we first\ncompute |piy|. This is an optimal policy for the second (last) step in\nthe sense that for every |x : X|, |piy x| is a \"best\" control, that is\n\n< p (x, piy x) = overline epsy (curry p x)\n\n< p (x, piy x)\n<\n< { Def. |piy| } \n<\n< p (x, epsy (\\ y => p (x, y)))\n<\n< { Def. |curry| }\n<\n< (curry p) x (epsy (\\ y => curry p x y))\n<\n< { Abstraction }\n<\n< (curry p) x (epsy (curry p x))\n<\n< { |overline e q = q (e q)| with |q = (curry p) x| and |e = epsy| }\n<\n< overline epsy (curry p x)\n\nThen, we compute |pix|. This is an optimal extension of |piy| in the\nsense that for every |u : Unit|, |pix u| is a \"best\" control *under the\nassumption that the next decision is taken with |piy|*, that is\n\n< p (pix u, piy (pix u)) = overline epsx (\\ x => p (x, (piy x)))\n\n< p (pix u, piy (pix u))\n<\n< { Def. |pix| }\n<\n< p (epsx (\\ x => p (x, piy x)), piy (epsx (\\ x => p (x, piy x))))\n<\n< { Let |g = \\ x => p (x, piy x)| }\n<\n< p (epsx g, piy (epsx g))\n<\n< { Def. |g| }\n<\n< g (epsx g)\n<\n< { Def. |overline| }\n<\n< overline epsx g\n<\n< { Def. |g| }\n<\n< overline epsx (\\ x => p (x, piy x))\n\nFinally, we compute |x| by applying the policy |pix| to |()| and then\n|y| by applying |piy| to |x|. It remains to show that |opairJ' epsx epsy\np = opairJ eosx epsy p| for all |epsx : J R X|, |epsy : J R Y| and |p :\n(X, Y) -> R|:\n\n< opairJ' epsx epsy p\n<\n< { Def. |opairJ'| }\n<\n< (x, y)\n<\n< { Def. |x| and |y| in |opairJ'| }\n<\n< (pix (), piy (pix ()))\n<\n< { Def. |pix ()| in |opairJ'| }\n<\n< (epsx (\\ x => p (x, piy x)), piy (epsx (\\ x => p (x, piy x))))\n<\n< { Def. |piy| in |opairJ'| }\n<\n< (epsx (\\ x => p (x, epsy (\\ y => p (x, y)))), piy (epsx (\\ x => p (x, epsy (\\ y => p (x, y))))))\n<\n< { Let |q x = \\ y => p (x, y)| }\n<\n< (epsx (\\ x => (q x) (epsy (q x))), piy (epsx (\\ x => (q x) (epsy (qx)))))\n<\n< { Def. |overline e p = p (e p)| with |p = q x| and |e = epsy| }\n<\n< (epsx (\\ x => overline epsy (q x)), piy (epsx (\\ x => overline epsy (q x))))\n<\n< { Def. |q x| }\n<\n< (epsx (\\ x => overline epsy (\\ y => p (x, y))), piy (epsx (\\ x => overline epsy (\\ y => p (x, y)))))\n<\n< { Def. |a| in |opairJ| }\n<\n< (a, piy a)\n<\n< { Def. |piy| in |opairJ'| }\n<\n< (a, epsy (\\ y => p (a, y)))\n<\n< { Def. |b| in |opairJ| }\n<\n< (a, b)\n< \n< { Def. |opairJ| }\n<\n< opairJ epsx epsy p\n\n\n\n** 3.2 Iterated product\n\nDefine the product of a \"sequence of sets |X 0|, |X 1|, ..., |X n|,\n...\". First we need a tail function for families of types:\n\n> Tail : (Nat -> Type) -> (Nat -> Type)\n> Tail X = \\ n => X (S n) \n\nThen we can define the product as a list\n\n> data Prod : (Nat -> Type) -> Type where\n> Nil : {X : Nat -> Type} -> Prod X\n> (::) : {X : Nat -> Type} -> (x : X Z) -> Prod (Tail X) -> Prod X\n\nWe cannot implement the iterated product in terms of |opairJ| because\nthe types of the arguments have to be in the relation implied by\n|Prod|. We need a more specific helper:\n\n> oprodJ : {X : Nat -> Type} -> {R : Type} ->\n> J R (X Z) -> J R (Prod (Tail X)) -> J R (Prod X) \n> oprodJ e ep p = a :: as where\n> a = e (\\ x => overline ep (\\ xs => p (x :: xs)))\n> as = ep (\\ xs => p (a :: xs))\n\nWith |oprodJ| implementing the iterated product is easy: \n\n> bigoprodJ : {X : Nat -> Type} -> {R : Type} ->\n> Prod ((J R) . X) -> J R (Prod X)\n> bigoprodJ Nil = \\ p => Nil\n> bigoprodJ (e :: es) = oprodJ e (bigoprodJ es)\n\nWe can do othe same with vectors instead of lists \n\n< data Prod : Nat -> (Nat -> Type) -> Type where\n< Nil : {X : Nat -> Type} -> Prod Z X\n< (::) : {n : Nat} -> {X : Nat -> Type} -> (x : X Z) -> Prod n (Tail X) -> Prod (S n) X\n\n< oprodJ : {X : Nat -> Type} -> {R : Type} -> {n : Nat} ->\n< J R (X Z) -> J R (Prod n (Tail X)) -> J R (Prod (S n) X) \n< oprodJ e ep p = a :: as where\n< a = e (\\ x => overline ep (\\ xs => p (x :: xs)))\n< as = ep (\\ xs => p (a :: xs))\n\n< bigoprodJ : {X : Nat -> Type} -> {R : Type} -> {n : Nat} -> \n< Prod n ((J R) . X) -> J R (Prod n X)\n< bigoprodJ Nil = \\ p => Nil\n< bigoprodJ (e :: es) = oprodJ e (bigoprodJ es)\n\nBecause they do not have dependent types, they implement |bigoprodJ| in\nHaskell for the special case of a constant family of types:\n\n> otimesJ : {X : Type} -> {R : Type} ->\n> J R X -> J R (List X) -> J R (List X) \n> otimesJ e ep p = a :: as where\n> a = e (\\ x => overline ep (\\ xs => p (x :: xs)))\n> as = ep (\\ xs => p (a :: xs))\n\n> bigotimesJ : {X, R : Type} -> List (J R X) -> J R (List X)\n> bigotimesJ Nil = \\ p => Nil\n> bigotimesJ (e :: es) = otimesJ e (bigotimesJ es)\n\n\n* 4. Playing games\n\n** 4.2 History dependent games\n\n-- > hotimesJ : {X : Type} -> {R : Type} ->\n-- > J R X -> (X -> J R (List X)) -> J R (List X) \n-- > hotimesJ e f p = a :: as where\n-- > a = e (\\ x => overline (f x) (\\ xs => p (x :: xs)))\n-- > as = (f a) (\\ xs => p (a :: xs))\n\n> hotimesJ : {X : Type} -> {R : Type} ->\n> J R X -> (X -> J R (List X)) -> J R (List X) \n> hotimesJ e0 e1 p = a0 :: a1\n> where\n> a0 = e0 (\\ x0 => overline (e1 x0) (\\ x1 => p (x0 :: x1)))\n> a1 = e1 a0 (\\ x1 => p (a0 :: x1))\n\n> bighotimesJ : {X, R : Type} -> List (List X -> J R X) -> J R (List X)\n> bighotimesJ [] = \\p => []\n> bighotimesJ (e :: es) = (e []) `hotimesJ` (\\x => bighotimesJ [\\ xs => d (x :: xs) | d <- es])\n\n\n** 4.3 Implementation of games and optimal strategies\n\n\n-- > data Game : Type -> Type -> Type where\n-- > MkGame : {Move, Outcome : Type} -> \n-- > (p : List Move -> Outcome) -> \n-- > (es : List (List Move -> J Outcome Move)) -> \n-- > Game Move Outcome\n\n-- > pred : {Move, Outcome : Type} -> Game Move Outcome -> (List Move -> Outcome)\n-- > pred (MkGame p _) = p\n\n-- > epss : {Move, Outcome : Type} -> Game Move Outcome -> List (List Move -> J Outcome Move)\n-- > epss (MkGame _ es) = es\n\n\n> {-\n> optimalStrategy : {Move, Outcome : Type} -> Game Move Outcome -> List Move -> Move\n> optimalStrategy {Move} {Outcome} g ms = head (optimalPlay g') where\n> g' : Game Move Outcome\n> g' = MkGame p' es' where\n> p' : List Move -> Outcome\n> p' = \\ ms' => (pred g) (ms ++ ms') \n> es' : List (List Move -> J Outcome Move)\n> es' = drop (length ms) (epss g)\n> -}\n\n\n** 4.5 Tic-Tac-Toe\n\n> data Player = X | O\n\n> Outcome : Type\n> Outcome = Int\n\n> Move : Type\n> Move = Int\n\n> Board : Type\n> Board = (List Move, List Move)\n\n\n\n\n\n> someContained : {X : Type} -> Ord X => \n> List (List X) -> List X -> Bool\n\n\n> wins : List Move -> Bool\n> wins = someContained [[0,1,2],[3,4,5],[6,7,8],\n> [0,3,6],[1,4,7],[2,5,8],\n> [0,4,8],[2,4,6]]\n\n> value : Board -> Outcome\n> value (xs, os) = if wins xs \n> then 1\n> else if wins os \n> then -1\n> else 0\n\n> insert : {X : Type} -> Ord X => X -> List X -> List X\n\n> outcome : Player -> List Move -> Board -> Board\n> outcome _ Nil board = board\n> outcome X (m :: ms) (xs, os) = if wins os \n> then (xs, os)\n> else outcome O ms (insert m xs, os)\n> outcome O (m :: ms) (xs, os) = if wins xs \n> then (xs, os)\n> else outcome X ms (xs, insert m os)\n\n\n> setMinus : {X : Type} -> Ord X => \n> List X -> List X -> List X\n\n-- > partial \n-- > es : List (List Move -> J Outcome Move)\n-- > es = take 3 all where\n-- > partial\n-- > eX : List Move -> J Outcome Move\n-- > eX = \\ h => argsup (setMinus [0..8] h)\n-- > partial\n-- > eO : List Move -> J Outcome Move\n-- > eO = \\ h => arginf (setMinus [0..8] h)\n-- > partial\n-- > all : List (List Move -> J Outcome Move)\n-- > all = [eX, eO, eX, eO, eX, eO, eX, eO, eX, eO]\n\n-- > partial\n-- > ticTacToe : Game Move Outcome\n-- > ticTacToe = MkGame p es\n\n\n> partial \n> epsilons : List (List Move -> J Outcome Move)\n> epsilons = take 3 all where\n> partial\n> eX : List Move -> J Outcome Move\n> eX = \\ h => argsup (setMinus [0..8] h)\n> partial\n> eO : List Move -> J Outcome Move\n> eO = \\ h => arginf (setMinus [0..8] h)\n> partial\n> all : List (List Move -> J Outcome Move)\n> all = [eX, eO, eX, eO, eX, eO, eX, eO, eX, eO]\n\n> p : List Move -> Outcome\n> p ms = value (outcome X ms (Nil, Nil))\n\n> partial\n> optimalPlay : List Move\n> optimalPlay = bighotimesJ epsilons p\n\n> partial\n> optimalOutcome : Outcome\n> optimalOutcome = p optimalPlay\n\n\n\n> partial\n> main : IO ()\n> main = \n> do putStr (\"An optimal play for Tic-Tac-Toe is \"\n> ++\n> show optimalPlay ++ \"\\n\"\n> ++\n> \"and the optimal outcome is \"\n> ++\n> show optimalOutcome ++ \"\\n\"\n> )\n\n\n** 4.7 Appendix\n\n> contained : {X : Type} -> Ord X => List X -> List X -> Bool\n> contained [] ys = True\n> contained xs [] = False\n> contained (x :: xs) (y :: ys) = if x == y \n> then contained xs ys\n> else if x >= y\n> then contained (x :: xs) ys\n> else False\n\n> someContained [] ys = False\n> someContained xss [] = False\n> someContained (xs :: xss) ys = contained xs ys || someContained xss ys\n\n> insert x [] = [x]\n> insert x (y :: ys) = if x == y \n> then (y :: ys)\n> else if x < y\n> then x :: (y :: ys)\n> else y :: (insert x ys) \n\n> delete : {X : Type} -> Ord X => X -> List X -> List X\n> delete x [] = []\n> delete x (y :: ys) = if x == y\n> then ys\n> else if x < y\n> then y :: ys\n> else y :: Main.delete x ys\n\n> setMinus xs [] = xs\n> setMinus xs (y :: ys) = setMinus (Main.delete y xs) ys\n\n> {-\n\n \n> ---}\n\n\n \n \n", "meta": {"hexsha": "f312203d5c484e623f181763ce9114f1a9bd772a", "size": 19432, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "EscardoOliva/SeqGamesTychonoffDoubleNegShift.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/SeqGamesTychonoffDoubleNegShift.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/SeqGamesTychonoffDoubleNegShift.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": 29.265060241, "max_line_length": 107, "alphanum_fraction": 0.5221799094, "num_tokens": 6637, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7690802476562643, "lm_q2_score": 0.7490872243177518, "lm_q1q2_score": 0.5761081879944401}}
{"text": "data ValidPassword : (min: Nat) -> (max: Nat) -> Type where\n MkPass: (xs: String) ->\n { auto p: length xs >= min && length xs <= max = True } ->\n ValidPassword min max\n\nvalidPassword : ValidPassword 4 8\nvalidPassword = MkPass \"abcd\"\n\ninvalidPassword : ValidPassword 4 8\ninvalidPassword = MkPass \"abcd\"\n\n-- see https://github.com/hackle/idris/blob/master/range.idr", "meta": {"hexsha": "95eac495e99ad7f67ab133a44537adb9856a6e2d", "size": 382, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/sample/isValidPassword.idr", "max_stars_repo_name": "hackle/blogger", "max_stars_repo_head_hexsha": "d32f496f0b4e6850f8f1327b5c66db234ba314f0", "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/sample/isValidPassword.idr", "max_issues_repo_name": "hackle/blogger", "max_issues_repo_head_hexsha": "d32f496f0b4e6850f8f1327b5c66db234ba314f0", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2020-04-11T07:14:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-11T10:04:31.000Z", "max_forks_repo_path": "src/sample/isValidPassword.idr", "max_forks_repo_name": "hackle/blogger", "max_forks_repo_head_hexsha": "d32f496f0b4e6850f8f1327b5c66db234ba314f0", "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.8333333333, "max_line_length": 68, "alphanum_fraction": 0.664921466, "num_tokens": 105, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8840392756357327, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.575823276758135}}
{"text": "||| Spec: https://webassembly.github.io/spec/core/valid/types.html#table-types\nmodule WebAssembly.Validation.Types.TableTypes\n\nimport WebAssembly.Structure\nimport WebAssembly.Validation.Types.Limits\n\npublic export\nMAX_LIMIT_TABLE : Nat\nMAX_LIMIT_TABLE = power 2 4 -- set to (power 2 32) for original WebAssembly behvaiour WARNING: type-checking then takes like forever\n\n-------------------------------------------------------------------------------\n-- Validation Rules\n-------------------------------------------------------------------------------\n\npublic export\ndata ValidTableType : TableType -> Type where\n MkValidTableType : (limits : Limits)\n -> (elementType : ElemType)\n -> (limits_valid: ValidLimits limits MAX_LIMIT_TABLE)\n -> ValidTableType (limits, elementType)\n\n-------------------------------------------------------------------------------\n-- Lemmas about table-type validation\n-------------------------------------------------------------------------------\n\ntotal invalid_limit : (contra : ValidLimits limits MAX_LIMIT_TABLE -> Void) -> ValidTableType (limits, elemType) -> Void\ninvalid_limit contra (MkValidTableType limits elemType limits_valid) = contra limits_valid\n\n-------------------------------------------------------------------------------\n-- Decidablity of Validation\n-------------------------------------------------------------------------------\n\ntotal public export\nisTableTypeValid : (tableType : TableType) -> Dec (ValidTableType tableType)\nisTableTypeValid (limits, elemType) = case (isLimitsValid limits MAX_LIMIT_TABLE) of\n No contra => No (invalid_limit contra)\n Yes prof => Yes (MkValidTableType limits elemType prof)\n", "meta": {"hexsha": "545edf875dcc5e66b1b88ed9d4a0327945aaeddc", "size": 1712, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "WebAssembly/Validation/Types/TableTypes.idr", "max_stars_repo_name": "RaoulSchaffranek/idris-webassembly", "max_stars_repo_head_hexsha": "ce77f5a5b612aad85eefe2374d22456d7d1edbb5", "max_stars_repo_licenses": ["Unlicense"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-11-07T16:03:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-07T16:03:42.000Z", "max_issues_repo_path": "WebAssembly/Validation/Types/TableTypes.idr", "max_issues_repo_name": "RaoulSchaffranek/idris-webassembly", "max_issues_repo_head_hexsha": "ce77f5a5b612aad85eefe2374d22456d7d1edbb5", "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": "WebAssembly/Validation/Types/TableTypes.idr", "max_forks_repo_name": "RaoulSchaffranek/idris-webassembly", "max_forks_repo_head_hexsha": "ce77f5a5b612aad85eefe2374d22456d7d1edbb5", "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": 45.0526315789, "max_line_length": 133, "alphanum_fraction": 0.5432242991, "num_tokens": 301, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8791467611766711, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.57574857994906}}
{"text": "--\n-- 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]. They support all the usual arithmetic\n-- operations: +,*,-,div, and mod. If the result y of an operation\n-- is outside the valid range, the unsigned remainder modulo 2^x of y\n-- is returned instead. The same kind of truncation happens when\n-- other numeric types are cast to one of the unsigned integer\n-- types.\n--\n-- Example: For `Bits8` the valid range is [0,255]. Below are some\n-- example calculations. All numbers are considered to be of type `Bits8`\n-- unless specified otherwise:\n--\n-- 255 + 7 = 6\n-- 3 * 128 = 128\n-- (-1) = 255\n-- 7 - 10 = 253\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]. They support all the usual arithmetic\n-- operations: +,*,-,div, and mod. If the result `y` of an operation\n-- is outside the valid range, the signed remainder modulo 2^x of `y`\n-- is calculated and 2^x subtracted from the result if it\n-- is still out of bounds. The same kind of truncation happens when\n-- other numeric types are cast to one of the signed integer\n-- types.\n--\n-- Example: For `Int8` the valid range is [-128,127]. Below are some\n-- example calculations. All numbers are considered to be of type `Int8`\n-- unless specified otherwise:\n--\n-- 127 + 7 = -122\n-- 3 * 64 = -64\n-- 2 * (-64) = -128\n-- (-129) = 127\n-- 7 - 10 = -3\n--\nimport Data.List\nimport Data.Stream\n\nrecord IntType (a : Type) where\n constructor MkIntType\n name : String\n signed : Bool\n precision : Integer\n min : Integer\n max : Integer\n\nintType : Bool -> String -> Integer -> IntType a\nintType True n p = let ma = prim__shl_Integer 1 (p - 1)\n in MkIntType n True p (negate ma) (ma - 1)\nintType False n p = let ma = prim__shl_Integer 1 p\n in MkIntType n False p 0 (ma - 1)\n\nbits8 : IntType Bits8\nbits8 = intType False \"Bits8\" 8\n\nbits16 : IntType Bits16\nbits16 = intType False \"Bits16\" 16\n\nbits32 : IntType Bits32\nbits32 = intType False \"Bits32\" 32\n\nbits64 : IntType Bits64\nbits64 = intType False \"Bits64\" 64\n\nint8 : IntType Int8\nint8 = intType True \"Int8\" 8\n\nint16 : IntType Int16\nint16 = intType True \"Int16\" 16\n\nint32 : IntType Int32\nint32 = intType True \"Int32\" 32\n\nint64 : IntType Int64\nint64 = intType True \"Int64\" 64\n\nint : IntType Int\nint = intType True \"Int\" 64\n\nrecord Op a where\n constructor MkOp\n name : String\n op : a -> a -> a\n opInt : Integer -> Integer -> Integer\n allowZero : Bool\n type : IntType a\n\nadd : Num a => IntType a -> Op a\nadd = MkOp \"+\" (+) (+) True\n\nsub : Neg a => IntType a -> Op a\nsub = MkOp \"-\" (-) (-) True\n\nmul : Num a => IntType a -> Op a\nmul = MkOp \"*\" (*) (*) True\n\ndiv : Integral a => IntType a -> Op a\ndiv = MkOp \"div\" (div) (div) False\n\nmod : Integral a => IntType a -> Op a\nmod = MkOp \"mod\" (mod) (mod) False\n\n\npairs : List (Integer,Integer)\npairs = let -- [1,2,4,8,16,...,18446744073709551616]\n powsOf2 = take 65 (iterate (*2) 1)\n\n -- powsOf2 ++ [0,1,3,7,...,18446744073709551615]\n naturals = powsOf2 ++ map (\\x => x-1) powsOf2\n\n -- positive and negative versions of naturals\n ints = naturals ++ map negate naturals\n\n -- naturals paired with ints\n in [| (,) ints naturals |]\n\n-- This check does the following: For a given binary operation `op`,\n-- calculate the result of applying the operation to all passed pairs\n-- of integers in `pairs` and check, with the given bit size, if\n-- the result is out of bounds. If it is, calculate the result\n-- modulo 2^bits. This gives the reference result as an `Integer`.\n--\n-- Now perform the same operation with the same input but for\n-- the integer type we'd like to check and cast the result back\n-- to an `Integer`. Create a nice error message for every pair\n-- that fails (returns an empty list if all goes well).\ncheck : (Num a, Cast a Integer) => Op a -> List String\ncheck (MkOp name op opInt allowZero $ MkIntType type signed bits mi ma) =\n let ps = if allowZero then pairs\n else filter ((0 /=) . checkBounds . snd) pairs\n in mapMaybe failing ps\n\n where\n trueMod : Integer -> Integer -> Integer\n trueMod x y = let res = x `mod` y\n in if res < 0 then res + y else res\n\n checkBounds : Integer -> Integer\n checkBounds n = let r1 = trueMod n (ma + 1 - mi)\n in if r1 > ma\n then r1 - (ma + 1 - mi)\n else r1\n\n failing : (Integer,Integer) -> Maybe String\n failing (x,y) =\n let resInteger = opInt x y\n resMod = checkBounds $ opInt (checkBounds x) (checkBounds y)\n resA = cast {to = Integer} (op (fromInteger x) (fromInteger y))\n in if resA == resMod\n then Nothing\n else Just #\"Error when calculating \\#{show x} \\#{name} \\#{show y} for \\#{type}: Expected \\#{show resMod} but got \\#{show resA} (unrounded: \\#{show resInteger})\"#\n\n--------------------------------------------------------------------------------\n-- Main\n--------------------------------------------------------------------------------\n\nmain : IO ()\nmain = do traverse_ putStrLn . check $ add int8\n traverse_ putStrLn . check $ sub int8\n traverse_ putStrLn . check $ mul int8\n traverse_ putStrLn . check $ div int8\n traverse_ putStrLn . check $ mod int8\n\n traverse_ putStrLn . check $ add int16\n traverse_ putStrLn . check $ sub int16\n traverse_ putStrLn . check $ mul int16\n traverse_ putStrLn . check $ div int16\n traverse_ putStrLn . check $ mod int16\n\n traverse_ putStrLn . check $ add int32\n traverse_ putStrLn . check $ sub int32\n traverse_ putStrLn . check $ mul int32\n traverse_ putStrLn . check $ div int32\n traverse_ putStrLn . check $ mod int32\n\n traverse_ putStrLn . check $ add int64\n traverse_ putStrLn . check $ sub int64\n traverse_ putStrLn . check $ mul int64\n traverse_ putStrLn . check $ div int64\n traverse_ putStrLn . check $ mod int64\n\n traverse_ putStrLn . check $ add int\n traverse_ putStrLn . check $ sub int\n traverse_ putStrLn . check $ mul int\n traverse_ putStrLn . check $ div int\n traverse_ putStrLn . check $ mod int\n\n traverse_ putStrLn . check $ add bits8\n traverse_ putStrLn . check $ sub bits8\n traverse_ putStrLn . check $ mul bits8\n traverse_ putStrLn . check $ div bits8\n traverse_ putStrLn . check $ mod bits8\n\n traverse_ putStrLn . check $ add bits16\n traverse_ putStrLn . check $ sub bits16\n traverse_ putStrLn . check $ mul bits16\n traverse_ putStrLn . check $ div bits16\n traverse_ putStrLn . check $ mod bits16\n\n traverse_ putStrLn . check $ add bits32\n traverse_ putStrLn . check $ sub bits32\n traverse_ putStrLn . check $ mul bits32\n traverse_ putStrLn . check $ div bits32\n traverse_ putStrLn . check $ mod bits32\n\n traverse_ putStrLn . check $ add bits64\n traverse_ putStrLn . check $ sub bits64\n traverse_ putStrLn . check $ mul bits64\n traverse_ putStrLn . check $ div bits64\n traverse_ putStrLn . check $ mod bits64\n", "meta": {"hexsha": "89c12220531c758af41933cdf9888ab5c3cafb60", "size": 7699, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "tests/chez/newints/IntOps.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/chez/newints/IntOps.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/chez/newints/IntOps.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": 35.1552511416, "max_line_length": 174, "alphanum_fraction": 0.5879984414, "num_tokens": 2042, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303087996143, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.5754866564221801}}
{"text": "module Toolkit.Data.List.Interleaving\n\n%default total\n\ninfixr 6 <::\ninfixr 6 ::>\n\npublic export\ndata Interleaving : (xs, ys, zs : List type) -> Type where\n Empty : Interleaving Nil Nil Nil\n\n Left : {xs,ys,zs : List type}\n -> (x : type)\n -> (rest : Interleaving xs ys zs)\n -> Interleaving (x::xs) ys (x::zs)\n Right : {xs,ys,zs : List type}\n -> (y : type)\n -> (rest : Interleaving xs ys zs)\n -> Interleaving xs (y::ys) (y::zs)\n\npublic export\n(<::) : {xs,ys,zs : List type}\n -> (x : type)\n -> (rest : Interleaving xs ys zs)\n -> Interleaving (x::xs) ys (x::zs)\n(<::) = Left\n\npublic export\n(::>) : {xs,ys,zs : List type}\n -> (y : type)\n -> (rest : Interleaving xs ys zs)\n -> Interleaving xs (y::ys) (y::zs)\n(::>) = Right\n", "meta": {"hexsha": "c300a4d0e25f00da6968a346fcd4fb75b9f2acf7", "size": 810, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Toolkit/Data/List/Interleaving.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/Interleaving.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/Interleaving.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": 23.8235294118, "max_line_length": 58, "alphanum_fraction": 0.5209876543, "num_tokens": 269, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.7401743563075447, "lm_q1q2_score": 0.5753374244029209}}
{"text": "module Sub03LTE216t81\n\nimport ProofColDivSeqBase\nimport ProofColDivSeqPostulate\n\n%default total\n\n\n-- 6(36t+13)+3 --DE[3,0,-4]--> 6(2t)+3\nexport\nlte216t81 : (m : Nat) -> LTE (S (m+m))\n (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)))))))\nlte216t81 Z = (lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . LTESucc) LTEZero\nlte216t81 (S m) =\n let lemma = lte216t81 m in\n\n rewrite (sym (plusSuccRightSucc m m)) in\n\n rewrite (sym (plusSuccRightSucc (plus m m) m)) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus m m) m) (S (S (plus (plus m m) m))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus m m) m) (S (plus (plus m m) m)))) in\n rewrite (sym (plusSuccRightSucc (plus (plus m m) m) (plus (plus m m) m))) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (S (S (S (S (S (plus (plus (plus m m) m) (plus (plus m m) m))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (S (S (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (S (S (S (plus (plus (plus m m) m) (plus (plus m m) m))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (S (plus (plus (plus m m) m) (plus (plus m m) m))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m)))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m)))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m)))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m)))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (S (S (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (S (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m)))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m)))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m)))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))\n (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m)))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))\n (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))\n (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m)))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))\n (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))\n (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m)))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))\n (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))\n (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m)))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))\n (S (S (S (S (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m)))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m) (plus (plus m m) m)))))\n (S (S (plus (plus (plus (plus m m) m) (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))\n (S (S (plus (plus (plus (plus m m) m)\n (plus (plus m m) m))\n (S (S (plus (plus (plus m m) m)\n (plus (plus m m) m))))))))) in\n\n (lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . LTESucc . LTESucc) lemma\n\n\n\n", "meta": {"hexsha": "cbb0f59aa3bd589b50da459c8b876c5b4b13c62e", "size": 20402, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "program3/Sub03LTE216t81.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/Sub03LTE216t81.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/Sub03LTE216t81.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": 91.0803571429, "max_line_length": 539, "alphanum_fraction": 0.2923732967, "num_tokens": 4776, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278664544912, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.5747736895041686}}
{"text": "> module Main\n\n> import Data.Fin\n> import Data.Vect\n> import Data.Matrix\n> import Data.Matrix.Numeric\n\n> import Fun.MathExpr\n> import Double.Properties\n> import Interfaces.Math\n\n> %default total\n> %access public export\n> %auto_implicits off\n\n\n* Preliminaries\n\nThis is a re-implementation of\n\n https://gist.github.com/mrkgnao/a45059869590d59f05100f4120595623 \n\nwhich, in turn, is an Idris implementation of\n\n https://blog.jle.im/entry/practical-dependent-types-in-haskell-1.html\n\n\n* Layers\n\nA layer of type |X| with |m| inputs and |n| outputs is a tuple\nconsisting of a function of type |X -> X|, a vector of |n| elements of\ntype |X| (the biases) and a |n| x |m| matrix of elements of type |X|\n(the weights):\n\n> Layer : (X : Type) -> (m : Nat) -> (n : Nat) -> Type\n> Layer X m n = (MathExpr X, Vect n X, Matrix n m X)\n\n\n* Sequential neural networks\n\nA sequential neural network of type |X| with |m| inputs, |n| outputs and\na sequence of intermediate layers is a sequence of layers of type\n|X|:\n\n> infixr 5 :>:\n\n> data Net : (X : Type) -> (m : Nat) -> List Nat -> (n : Nat) -> Type where\n> Id : {X : Type} -> {m : Nat} -> \n> Net X m [] m\n> (:>:) : {X : Type} -> {m, m', n : Nat} -> {ms' : List Nat} -> \n> Layer X m m' -> Net X m' ms' n -> Net X m (m' :: ms') n\n\n\n* Feed-forward\n\nThe idea is that, given a sequential neural network of type |X| with |m|\ninputs and |n| outputs and a vector of |m| inputs of matching type, one\ncan compute a vector of |n| outputs. The computation is called\nfeed-forward.\n\n> ff : {X : Type} -> {m, n : Nat} -> {ms : List Nat} -> \n> (Num X, Fractional X, Neg X, Math X) => \n> Net X m ms n -> Vect m X -> Vect n X\n> ff Id x = id x\n> ff ((s, b, w) :>: ls) x = ff ls (map (eval s) (b + (w > x)))\n\n\n* Error\n\nGiven a training pair |(x, y)|, the error is simply the difference\nbetween |y| and the output of the network when fed with the input |x|:\n\n> error : {X : Type} -> {n, m : Nat} -> {ms : List Nat} -> \n> (Num X, Fractional X, Neg X, Math X) => \n> Net X m ms n -> Vect m X -> Vect n X -> Vect n X\n> error net x y = y - (ff net x)\n\n\n* Gradients\n\n> nInputs : {X : Type} -> {m : Nat} -> {n : Nat} -> Layer X m n -> Nat\n> nInputs {m} _ = m\n\n> nOutputs : {X : Type} -> {m : Nat} -> {n : Nat} -> Layer X m n -> Nat\n> nOutputs {n} _ = n\n\n> nLayers : {X : Type} -> {m, n : Nat} -> {ms : List Nat} -> \n> Net X m ms n -> Nat\n> nLayers Id = Z\n> nLayers (l :>: ls) = S (nLayers ls)\n\n> dimOutputs : {X : Type} -> {m, n : Nat} -> {ms : List Nat} -> \n> Net X m ms n -> List Nat\n> dimOutputs Id = []\n> dimOutputs (l :>: ls) = (nOutputs l) :: (dimOutputs ls)\n\n> data ListVect : List Nat -> Type -> Type where\n> Nil : {X : Type} -> \n> ListVect [] X\n> (::) : {m : Nat} -> {ms : List Nat} -> {X : Type} -> \n> Vect m X -> ListVect ms X -> ListVect (m :: ms) X\n\n> gradZ : {X : Type} -> {m, m', n : Nat} -> {ms' : List Nat} -> \n> (Num X, Fractional X, Neg X, Math X) =>\n> (f : Vect n X -> X) -> \n> (net : Net X m (m' :: ms') n) -> \n> ListVect (dimOutputs net) X\n\n\n\n\n\n> {-\n\n> -}\n\n\n* Back propagation\n\n> backPropagation : {X : Type} -> {m, m', n : Nat} -> {ms' : List Nat} -> \n> (Num X, Fractional X, Neg X, Math X) => \n> (eta : X) ->\n> (x : Vect m X) ->\n> (y : Vect n X) ->\n> Net X m (m' :: ms') n -> \n> Net X m (m' :: ms') n\n\n> backPropagation {X} eta x y net = fst (go x y net)\n> \n> where go : {m, m', n : Nat} -> {ms' : List Nat} ->\n> Vect m X -> \n> Vect n X -> \n> Net X m (m' :: ms') n -> (Net X m (m' :: ms') n, Vect m X)\n> \n> go x y ((s, b, w) :>: Id) =\n> let z = b + (w > x)\n> x' = map (eval s) z\n> dEdy = (map (eval (derivative s)) z) * (x' - y)\n> b' = b - (eta <# dEdy)\n> w' = w - (eta <#> (dEdy >< x))\n> dWs = (transpose w) > dEdy\n> in ((s, b', w') :>: Id, dWs)\n> \n> go x y ((s, b, w) :>: l :>: ls) =\n> let z = b + (w > x)\n> x' = map (eval s) z\n> (l' :>: ls', dWs') = go x' y (l :>: ls)\n> dEdy = (map (eval (derivative s)) z) * dWs'\n> b' = b - (eta <# dEdy)\n> w' = w - (eta <#> (dEdy >< x))\n> dWs = (transpose w) > dEdy\n> in ((s, b', w') :>: l' :>: ls', dWs)\n\n\n* Example\n\n> s : MathExpr Double\n> s = (Const 1) / (Const 1 + Exp . Neg)\n\n> initial : Net Double 2 [2,2] 2 \n> initial = (s, [0.35, 0.35], [[0.15, 0.20], [0.25, 0.30]])\n> :>:\n> (s, [0.60, 0.60], [[0.40, 0.45], [0.50, 0.55]]) \n> :>: \n> Id\n\n> input : Vect 2 Double\n> input = [0.05, 0.10]\n\n> target : Vect 2 Double\n> target = [0.01, 0.99]\n\n> main : IO ()\n> main = let step = backPropagation 0.5 input target\n> errorF = \\ net => error net input target\n> states = iterate step initial\n> in putStrLn . unlines $ map (show . errorF) (take 100 states)\n\n\n> {-\n\n> ---}\n\n\n\n\n\n\n \n", "meta": {"hexsha": "da3eef18efb5f254b56cceae1925a48a4ace22ce", "size": 5249, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "NeuralNetworks/Theory.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": "NeuralNetworks/Theory.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": "NeuralNetworks/Theory.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.6263157895, "max_line_length": 75, "alphanum_fraction": 0.4640883978, "num_tokens": 1815, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8824278602705732, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.5747736854762434}}
{"text": "||| Dependently typed implementation of an Integer Map based on\n||| _big-endian_ Patricia trees. Dependent types are used to encode\n||| bit size of keys and to enforce some invariants for data structure.\n|||\n||| Algorithm is taken from Chris Okasaki and Andy Gill,\n||| \"Fast Mergeable Integer Maps\", Workshop on ML, September 1998, pages 77-86.\n||| Some implementation details are taken from\n||| [Haskell implementation](http://hackage.haskell.org/package/containers-0.5.10.1/docs/Data-IntMap.html).\n|||\n||| Most functions have `O(min(n, W))` running time, where `n` is number of elements\n||| and `W` is size of bits to store key.\n\nmodule Patricia.IntMap\n\nimport Data.Bits\nimport Data.Fin\n\nimport Patricia.BitsUtils\n\n%default total\n%access export\n\n||| The core patricia tree data structure used to represent integer key-value map.\n|||\n||| @bits Number of bits in `key`.\n||| @valTy The type associated with the value.\npublic export\ndata IntBitMap : (bits : Nat) -> (valTy : Type) -> Type where\n ||| An empty `IntBitMap` node.\n Empty : IntBitMap (S n) v\n\n ||| A Leaf node in the Tree.\n |||\n ||| @n Number of bits in key.\n ||| @key The key: integer of `n` bits.\n ||| @val The value associated with the key.\n Leaf : (key : Bits (S n))\n -> (val : v)\n -> IntBitMap (S n) v\n\n ||| A binary node in the tree.\n |||\n ||| *Invariant:* `Empty` is never found as a child of `Bin`. TODO: encode this\n |||\n ||| @n Number of bits in key.\n-- ||| @leftPrf Proof that left subtree is not `Empty`\n-- ||| @rightPrf Proof that right subtree is not `Empty`\n ||| @pref The common high-order bits that all elements share to the left of\n ||| the `brBit` bit. Bit at `brBit` is set to `0` and all the lesser bits to `1`.\n ||| @brBit The largest bit position in `pref` at which two elements of the set differ.\n ||| @left The left child of the Binary Node.\n ||| @right The right child of the Binary Node.\n Bin : -- {auto leftPrf : NonEmptyPatricia left}\n -- {auto rightPrf : NonEmptyPatricia right}\n (pref : Bits (S n))\n -> (brBit : Fin (S n))\n -> (left : IntBitMap (S n) v)\n -> (right : IntBitMap (S n) v)\n -> IntBitMap (S n) v\n\n-- ||| Invariant for `IntBitMap` that it's not empty.\n-- |||\n-- ||| @tree Tree for which invariant holds.\n-- data NonEmptyPatricia : (tree : IntBitMap n v) -> Type where\n-- ||| Invariant for `Leaf` constructor.\n-- NonEmptyLeaf : NonEmptyPatricia (Leaf key val)\n--\n-- ||| Invariant for `Bin` constructor.\n-- |||\n-- ||| @left Implicit param for left subtree.\n-- ||| @right Implicit param for right subtree.\n-- ||| @leftPrf Proof that @left subtree is not empty.\n-- ||| @rightPrf Proof that @right subtree is not empty.\n-- NonEmptyBin : {left : IntBitMap (S n) v}\n-- -> {right : IntBitMap (S n) v}\n-- -> (leftPrf : NonEmptyPatricia left)\n-- -> (rightPrf : NonEmptyPatricia right)\n-- -> NonEmptyPatricia (Bin pref bit left right)\n\n%name IntBitMap t, tree\n\n-- TODO: not total?\n-- Uninhabited (NonEmptyPatricia Empty) where\n-- uninhabited NonEmptyLeaf impossible\n-- uninhabited (NonEmptyBin _ _) impossible\n\nFunctor (IntBitMap (S n)) where\n map _ Empty = Empty\n map f (Leaf key val) = Leaf key (f val)\n map f (Bin pref brBit left right) = Bin pref brBit (map f left) (map f right)\n\nFoldable (IntBitMap (S n)) where\n foldr _ acc Empty = acc\n foldr f acc (Leaf _ val) = f val acc\n foldr f acc (Bin _ _ left right) = foldr f (foldr f acc right) left\n\n||| Integer map with 32 bits integers as a key.\npublic export\nInt32Map : (valTy : Type) -> Type\nInt32Map v = IntBitMap 32 v\n\n||| `O(n)`. Number of elements in `IntBitMap`.\npublic export\nsize : IntBitMap (S n) v -> Nat\nsize Empty = 0\nsize (Leaf _ _) = 1\nsize (Bin _ _ left right) = size left + size right\n\n||| `O(min(n, W))`. Lookup the value at a key in the `IntBitMap`.\npublic export\nlookup : Integer -> IntBitMap (S n) v -> Maybe v\nlookup {n} key t with (intToBits {n=S n} key)\n lookup {n} key t | bitKey = go t where\n go : IntBitMap (S n) v -> Maybe v\n go Empty = Nothing\n go (Leaf treeKey val) = if treeKey == bitKey then Just val else Nothing\n go (Bin pref _ left right) = if bitKey <= pref -- we can compare `key` with `pref` because of BE patricia trees\n then go left\n else go right\n\n||| `O(W)`. Joins two nodes into one tree, creating `Bin` node.\n||| Both nodes should be not `Empty`.\nprivate\njoinNodes : IntBitMap (S n) v -> IntBitMap (S n) v -> IntBitMap (S n) v\njoinNodes Empty _ = Empty -- TODO: ensure at compile time\njoinNodes _ Empty = Empty -- TODO: ensure at compile time\njoinNodes {n} t1 t2 = let bBit = branchingBit pref1 pref2\n prefMask = maskInsignificant bBit pref1\n in if isZeroBit bBit pref1\n then Bin prefMask bBit t1 t2\n else Bin prefMask bBit t2 t1\n where\n pref : IntBitMap (S n) v -> Bits (S n)\n pref Empty = cast 0 -- TODO: ensure this never happens\n pref (Leaf key _) = key\n pref (Bin p _ _ _) = p\n\n pref1 : Bits (S n)\n pref1 = pref t1\n\n pref2 : Bits (S n)\n pref2 = pref t2\n\n||| `O(min(n,W))`. Insert a new `(key,value)` pair in the `IntBitMap`.\n||| If the key is already present in the map, the associated value is\n||| replaced with the supplied value.\npublic export\ninsert : Integer -> v -> IntBitMap (S n) v -> IntBitMap (S n) v\ninsert {n} key val t with (intToBits {n=S n} key)\n insert {n} key val t | bitKey = go t where\n go : IntBitMap (S n) v -> IntBitMap (S n) v\n go Empty = Leaf bitKey val\n\n go lf@(Leaf oldKey oldVal) =\n if oldKey == bitKey\n then Leaf bitKey val\n else joinNodes lf (Leaf bitKey val)\n\n go br@(Bin pref brBit left right) =\n if matchPrefix brBit pref bitKey\n then if isZeroBit brBit bitKey -- bitKey <= pref\n then Bin pref brBit (go left) right\n else Bin pref brBit left (go right)\n else joinNodes br (Leaf bitKey val)\n\n||| `O(min(n,W))`. Delete `key` with corresponding `value` from `IntBitMap`.\n||| If the key is not present in the map, the tree isn't changed.\npublic export\ndelete : Integer -> IntBitMap (S n) v -> IntBitMap (S n) v\ndelete {n} key t with (intToBits {n=S n} key)\n delete {n} key t | bitKey = go t where\n go : IntBitMap (S n) v -> IntBitMap (S n) v\n go Empty = Empty\n go lf@(Leaf oldKey val) = if oldKey == bitKey then Empty else lf\n go (Bin pref _ left right) =\n if bitKey <= pref then case go left of\n Empty => right\n tree => joinNodes tree right\n else case go right of\n Empty => left\n tree => joinNodes left tree\n\n||| Create `IntBitMap` from list of `(key, value)`.\npublic export\nfromList : List (Integer, v) -> IntBitMap (S n) v\nfromList = foldl insertKeyValPair Empty where\n insertKeyValPair : IntBitMap (S n) v -> (Integer, v) -> IntBitMap (S n) v\n insertKeyValPair tree (key, val) = insert key val tree\n\nvalues : IntBitMap (S n) v -> List v\nvalues = toList\n", "meta": {"hexsha": "70a7afe5b7da906d5ac1301734961488065c43b5", "size": 7341, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Patricia/IntMap.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/IntMap.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/IntMap.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": 38.234375, "max_line_length": 116, "alphanum_fraction": 0.6063206648, "num_tokens": 2159, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8104789178257653, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.5746450652511715}}
{"text": "module Main\n\nimport Data.Vect\nimport Data.Fin\n\n%language DSLNotation\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 lookup Stop [] impossible\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 : Lazy (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 %static\n lam_ : TTName -> Expr (a :: G) t -> Expr G (TyFun a t)\n lam_ _ = Lam\n\n dsl expr\n lambda = lam_\n variable = Var\n index_first = Stop\n index_next = Pop\n\n total\n interp : Env G -> %static (e : 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 = Lam (App (App (Lam (Lam (Op' (+) (Var FZ) (Var (FS FZ))))) (Var FZ)) (Var FZ))\n\n eDouble : Expr G (TyFun TyInt TyInt)\n eDouble = expr (\\x => App (App eAdd x) (Var Stop))\n\n-- app : Lazy (Expr G (TyFun a t)) -> Expr G a -> Expr G t\n-- app = \\f, a => App (Force f) a\n\n eFac : Expr G (TyFun TyInt TyInt)\n eFac = expr (\\x => If (Op (==) x (Val 0))\n (Val 1)\n (Op (*) (App eFac (Op (-) x (Val 1))) x))\n\n -- Exercise elaborator: Complicated way of doing \\x y => x*4 + y*2\n\n eProg : Expr G (TyFun TyInt (TyFun TyInt TyInt))\n eProg = Lam (Lam\n (Bind (App eDouble (Var (Pop Stop)))\n (\\x => Bind (App eDouble (Var Stop))\n (\\y => Bind (App eDouble (Val x))\n (\\z => App (App eAdd (Val y)) (Val z))))))\n\ntest : Int\ntest = interp [] eProg 2 2\n\ntestFac : Int\ntestFac = interp [] eFac 4\n\ntestEnv : Int -> Env [TyInt,TyInt]\ntestEnv x = [x,x]\n\nmain : IO ()\nmain = do { printLn testFac\n printLn test }\n\n\n", "meta": {"hexsha": "b955cf33d49877f0ed0c489e10e90b5d04686be7", "size": 3034, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "test/idris-dev/dsl001/test001.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/dsl001/test001.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/dsl001/test001.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": 28.6226415094, "max_line_length": 93, "alphanum_fraction": 0.5385629532, "num_tokens": 1050, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424373085146, "lm_q2_score": 0.6791787121629465, "lm_q1q2_score": 0.574546095135181}}
{"text": "||| An expression language with mechanical proof of type-safety.\n|||\n||| `Variant` is an expression language supporting Let-bindings, and\n||| type safe 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.3 of the Functional Pearl.\n|||\n||| Although the code appears to be total, there is a known issues\n||| with Idris2 totality checker that causes it to slow down when\n||| dealing with mutually defined terms.\n|||\nmodule Razor.Variant.Unique\n\nimport Razor.Common\n\n%default covering\n\nnamespace Types\n\n public export\n data Level = TYPE | VALUE\n\n public export\n data Ty : Level -> Type where\n IntTyDesc : Ty TYPE\n IntTy : Ty VALUE\n\n CharTyDesc : Ty TYPE\n CharTy : Ty VALUE\n\n VariantTyDesc : (fields : Vect (S n) (Ty TYPE)) -> Ty TYPE\n VariantTy : (fields : Vect (S n) (Ty VALUE)) -> Ty VALUE\n\n public export\n data TyCheckVariant : (prfTy : (desc : Ty TYPE) -> (type : Ty VALUE) -> Type)\n -> (fieldsD : Vect (S n) (Ty TYPE))\n -> (fieldsV : Vect (S n) (Ty VALUE))\n -> Type\n where\n CheckOne : (prf : check type value) -> TyCheckVariant check [type] [value]\n CheckRest : (one : check type value)\n -> (rest : TyCheckVariant check types values)\n -> TyCheckVariant check (type::types) (value::values)\n\n\n public export\n data TyCheck : (desc : Ty TYPE)\n -> (type : Ty VALUE)\n -> Type\n where\n CheckInt : TyCheck IntTyDesc IntTy\n CheckChar : TyCheck CharTyDesc CharTy\n CheckVar : (prf : TyCheckVariant TyCheck types values)\n -> TyCheck (VariantTyDesc types) (VariantTy values)\n\nnamespace Context\n public export\n Context : List Level -> Type\n Context = DList Level Ty\n\n public export\n Elem : {level : Level}\n -> {levels : List Level}\n -> (ctxt : Context levels)\n -> (type : Ty level)\n -> Type\n Elem ctxt type = Elem Level Ty type ctxt\n\nnamespace Terms\n mutual\n\n namespace Patterns\n public export\n data Case : (ctxt : Context levels)\n -> (type : Ty VALUE)\n -> (body : Ty level)\n -> Type\n where\n MkCase : {type : Ty VALUE}\n -> {body : Ty level}\n -> (branch : Variant (ctxt += type) body)\n -> Case ctxt type body\n\n public export\n data Cases : (ctxt : Context levels)\n -> (types : Vect (S n) (Ty VALUE))\n -> (body : Ty level)\n -> Type\n where\n Singleton : {type : Ty VALUE}\n -> {body : Ty level}\n -> (branch : Case ctxt type body)\n -> Cases ctxt [type] body\n\n Extend : {type : Ty VALUE}\n -> {body : Ty level}\n -> (branch : Case ctxt type body)\n -> (rest : Cases ctxt kvs body)\n -> Cases ctxt (type :: kvs) body\n\n namespace Delcarations\n public export\n data Field : (ctxt : Context levels)\n -> (type : Ty TYPE)\n -> Type\n where\n MkField : {type : Ty TYPE}\n -> (desc : Variant ctxt type)\n -> Field ctxt type\n\n public export\n data Fields : (ctxt : Context levels)\n -> (kvs : Vect (S n) (Ty TYPE))\n -> Type\n where\n Singleton : (field : Field ctxt type)\n -> Fields ctxt [type]\n\n Extend : (field : Field ctxt type)\n -> (rest : Fields ctxt fields)\n -> Fields ctxt (fields += type)\n\n\n public export\n data Variant : forall lvls, lvl . Context lvls -> Ty lvl -> Type where\n -- Let-Bindings & Variables\n Var : Elem g ty -> Variant g ty\n\n Let : {expr : Ty levelE}\n -> {body : Ty levelB}\n -> (this : Variant g expr)\n -> (beInThis : Variant (expr::g) body)\n -> Variant g body\n\n -- Base Values\n I : Int -> Variant g IntTy\n C : Char -> Variant g CharTy\n\n -- Type Constructors\n TyInt : Variant g IntTyDesc\n TyChar : Variant g CharTyDesc\n\n TyVariant : {kvs : Vect (S n) (Ty TYPE)}\n -> (fields : Fields g kvs)\n -> Variant g (VariantTyDesc kvs)\n\n -- Variant Value Constructors\n Tag : {ty : Ty VALUE}\n -> {types : Vect (S n) (Ty TYPE)}\n -> {values : Vect (S n) (Ty VALUE)}\n -> (value : Variant g ty)\n -> (type : Variant g (VariantTyDesc types))\n -> (chk : TyCheck (VariantTyDesc types) (VariantTy values))\n -> (prf : Elem ty values)\n -> Variant g (VariantTy values)\n\n -- Variant Matching\n Match : {values : Vect (S n) (Ty VALUE)}\n -> (value : Variant g (VariantTy values))\n -> (cases : Cases g values b)\n -> Variant g b\n\n\nnamespace Renaming\n\n public export\n weaken : (f : Context.Elem old type\n -> Context.Elem new type)\n -> (Context.Elem (old += type') type\n -> Context.Elem (new += type') type)\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 levelsO, levelsN\n . {old : Context levelsO}\n -> {new : Context levelsN}\n -> (forall level . {type : Ty level}\n -> Context.Elem old type\n -> Context.Elem new type)\n\n -> ({type : Ty VALUE} ->\n {body : Ty level} -> Case old type body\n -> Case new type body)\n rename f (MkCase branch)\n = MkCase (rename (weaken f) branch)\n\n namespace Cases\n public export\n rename : forall levelsO, levelsN\n . {old : Context levelsO}\n -> {new : Context levelsN}\n -> (f : forall level\n . {type : Ty level}\n -> Context.Elem old type\n -> Context.Elem new type)\n\n -> (forall types . Cases old types type\n -> Cases new types type)\n\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\n namespace Fields\n public export\n rename : forall levelsO, levelsN\n . {old : Context levelsO}\n -> {new : Context levelsN}\n -> (f : forall level . {type : Ty level}\n -> Context.Elem old type\n -> Context.Elem new type)\n -> (forall types . Fields old types\n -> Fields new types)\n\n rename f (Singleton (MkField first))\n = Singleton (MkField (rename f first))\n\n rename f (Extend (MkField next) rest)\n = Extend (MkField (rename f next)) (rename f rest)\n\n\n public export\n rename : forall levelsO, levelsN\n . {old : Context levelsO}\n -> {new : Context levelsN}\n -> (f : forall level . {type : Ty level}\n -> Elem old type\n -> Elem new type)\n -> (forall level . {type : Ty level}\n -> Variant old type\n -> Variant new type)\n -- Let Binding & Variables\n rename f (Var x) = Var (f x)\n rename f (Let this beInThis)\n = Let (rename f this) (rename (weaken f) beInThis)\n\n -- Base Values\n rename f (I x) = I x\n rename f (C x) = C x\n\n -- Type Constructors\n rename f (TyInt) = TyInt\n rename f (TyChar) = TyChar\n rename f (TyVariant fields) = TyVariant (rename f fields)\n\n -- Variant Value Constructors\n rename f (Tag value type chk prf)\n = Tag (rename f value) (rename f type) chk prf\n\n -- Variant Matching\n rename f (Match value cases)\n = Match (rename f value) (rename f cases)\n\n\nnamespace Substitution\n\n public export\n weakens : forall levelsO, levelsN\n . {old : Context levelsO}\n -> {new : Context levelsN}\n -> {type : Ty level}\n -> {type' : Ty level'}\n -> (f : Elem old type\n -> Variant new type)\n -> (Elem (old += type') type\n -> Variant (new += type') type)\n weakens func Here = Var Here\n weakens func (There rest) = rename There (func rest)\n\n\n namespace General\n mutual\n namespace Fields\n public export\n subst : forall levelsO, levelsN\n . {old : Context levelsO}\n -> {new : Context levelsN}\n -> (f : forall level\n . {type : Ty level}\n -> Elem old type\n -> Variant new type)\n\n -> (forall types . Fields old types\n -> Fields new types)\n\n subst f (Singleton (MkField desc))\n = Singleton (MkField (subst f desc))\n\n subst f (Extend (MkField desc) rest)\n = Extend (MkField (subst f desc)) (subst f rest)\n\n\n namespace Case\n public export\n subst : forall levelsO, levelsN\n . {old : Context levelsO}\n -> {new : Context levelsN}\n -> (f : forall level\n . {type : Ty level}\n -> Elem old type\n -> Variant new type)\n -> ({type : Ty VALUE} ->\n {body : Ty level} -> Case old type body\n -> Case new type body)\n subst f (MkCase branch)\n = MkCase (subst (weakens f) branch)\n\n namespace Cases\n public export\n subst : forall levelsO, levelsN\n . {old : Context levelsO}\n -> {new : Context levelsN}\n -> (f : forall level\n . {type : Ty level}\n -> Elem old type\n -> Variant new type)\n -> (forall types . 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 public export\n subst : forall levelsO, levelsN\n . {old : Context levelsO}\n -> {new : Context levelsN}\n -> (f : forall level\n . {type : Ty level}\n -> Elem old type\n -> Variant new type)\n -> (forall level . {type : Ty level}\n -> Variant old type\n -> Variant new type)\n -- Let-Binding & 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 -- Type Constructors\n subst f TyInt = TyInt\n subst f TyChar = TyChar\n\n subst f (TyVariant fields)\n = TyVariant (subst f fields)\n\n -- Variant Value Constructors\n subst f (Tag value type chk prf)\n = Tag (subst f value) (subst f type) chk prf\n\n -- Variant Matching\n subst f (Match value cases)\n = Match (subst f value) (subst f cases)\n\n\n namespace Single\n public export\n apply : forall levelA, levelB\n . {typeA : Ty levelA}\n -> {typeB : Ty levelB}\n -> (this : Variant ctxt typeB)\n -> (idx : Elem (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 : forall levelA, levelB\n . {typeA : Ty levelA}\n -> {typeB : Ty levelB}\n -> {ctxt : Context lvls}\n -> (this : Variant ctxt typeB)\n -> (inThis : Variant (ctxt += typeB) typeA)\n -> Variant ctxt typeA\n subst this inThis = General.subst (Single.apply this) inThis\n\n\nnamespace Values\n mutual\n namespace Field\n public export\n data Value : (field : Field g type) -> Type where\n MkField : (prf : Value field)\n -> Value (MkField field)\n\n namespace Fields\n public export\n data Value : (fields : Fields g types) -> Type where\n Singleton : {field : Field g type}\n -> (prf : Value field)\n -> Value (Singleton field)\n\n Extend : {field : Field g type}\n -> {fields : Fields g kvs}\n -> (prf : Field.Value field)\n -> (rest : Fields.Value fields)\n -> Value (Extend field fields)\n public export\n data Value : Variant ctxt type -> Type where\n -- Base Values\n I : Value (I i)\n C : Value (C c)\n\n\n -- Type Constructors\n TyInt : Value TyInt\n TyChar : Value TyChar\n\n TyVariant : Value fields\n -> Value (TyVariant fields)\n\n\n -- Variant Value Constructors\n Tag : {types : Vect (S n) (Ty TYPE)}\n -> {type : Variant g (VariantTyDesc types)}\n\n -> {values : Vect (S n) (Ty VALUE)}\n\n -> {chk : TyCheck (VariantTyDesc types) (VariantTy values)}\n\n -> {value : Variant g value_type}\n\n -> {idx : Elem value_type values}\n\n -> (prfT : Value type)\n -> (prfV : Value value)\n\n -> Value (Tag value type chk idx)\n\n\nnamespace Reduction\n\n namespace Cases\n public export\n data Redux : (value : Variant g type)\n -> (cases : Cases g types body)\n -> (idx : Elem type types)\n -> (result : Variant g body)\n -> Type\n where\n ReduceSingleton : {value : Variant g type}\n -> {branch : Variant (type::g) type'}\n -> Value value\n -> Redux value\n (Singleton (MkCase branch))\n Here\n (subst value branch)\n ReduceExtend : {value : Variant g type}\n -> {rest : Cases g types body}\n -> Value value\n -> Redux value\n (Extend (MkCase branch) rest)\n Here\n (subst value branch)\n\n SkipThis : Redux value rest later result\n -> Redux value\n (Extend branch rest)\n (There later)\n result\n\n mutual\n namespace Field\n public export\n data Redux : (this, that : Field ctxt type) -> Type where\n SimplifyField :{this, that : Variant g type}\n -> (prf : Redux this that)\n -> Redux (MkField this) (MkField that)\n\n namespace Fields\n public export\n data Redux : (this, that : Fields g types) -> Type where\n SimplifySingleton : {this, that : Field g type}\n -> (prf : Redux this that)\n -> Redux (Singleton this) (Singleton that)\n\n SimplifyExtendValue : {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 SimplifyExtendRest : {this, that : Fields ctxt types}\n -> {field : Field ctxt type}\n -> (value : Field.Value field)\n -> (rest : Redux this that)\n -> Redux (Extend field this)\n (Extend field that)\n\n public export\n data Redux : (this, that : Variant ctxt type) -> Type where\n -- Let Bindings\n SimplifyLetValue : {this, that : Variant ctxt typeV}\n -> {body : Variant (ctxt += typeV) typeB}\n -> (redux : Redux this that)\n -> Redux (Let this body)\n (Let that body)\n\n ReduceLetBody : {value : Variant ctxt typeV}\n -> {body : Variant (ctxt += typeV) typeB}\n -> (prfV : Value value)\n -> Redux (Let value body)\n (subst value body)\n\n -- Variant Type Constructors\n SimplifyTyVariant : Redux this that\n -> Redux (TyVariant this)\n (TyVariant that)\n\n -- Variant Value Constructors\n SimplifyTagType : {this, that : Variant ctxt (VariantTyDesc kvs)}\n -> {value : Variant ctxt type}\n -> (redux : Redux this that)\n -> Redux (Tag value this chk idx)\n (Tag value that chk idx)\n\n SimplifyTagValue : {type : Variant ctxt (VariantTyDesc types)}\n -> (prfT : Value type)\n -> {this, that : Variant ctxt type'}\n -> (redux : Redux this that)\n -> Redux (Tag this type chk idx)\n (Tag that type chk idx)\n\n -- Variant Matching\n SimplifyMatchCase : {cases : Cases ctxt kvs type}\n -> (redux : Redux this that)\n -> Redux (Match this cases) (Match that cases)\n\n ReduceCases : {value : Variant g type_value}\n -> {type : Variant g (VariantTyDesc types)}\n\n -> {this : Cases g kvs body}\n -> {that : Variant g body}\n\n -> (prfV : Value value)\n -> (prfT : Value type)\n -> (redux : Redux value this idx that)\n -> Redux (Match (Tag value type chk idx) this)\n that\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 Step : {this, that : Variant 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 : Value field) -> Progress field\n\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 namespace Cases\n public export\n data Progress : (value : Variant Nil type)\n -> (idx : Elem type kvs)\n -> (term : Cases Nil kvs body)\n -> Type\n where\n Step : {value : Variant Nil type'}\n -> {idx : Elem type' kvs}\n -> {cases : Cases Nil kvs type}\n -> {that : Variant Nil type}\n -> (step : Redux value cases idx that)\n -> Progress value idx cases\n\n -- The body is defined later on.\n public export\n progress : (term : Variant Nil type) -> Progress term\n\n mutual\n namespace Field\n public export\n progress : (field : Field Nil type) -> Progress field\n progress (MkField desc) with (Progress.progress desc)\n progress (MkField desc) | (Done value) = Done (MkField value)\n progress (MkField desc) | (Step step) = Step (SimplifyField step)\n\n\n namespace Fields\n public export\n progress : (fields : Fields Nil types) -> Progress fields\n progress (Singleton field) with (Field.progress field)\n progress (Singleton field) | (Done value) = Done (Singleton value)\n progress (Singleton field) | (Step step) = Step (SimplifySingleton step)\n\n progress (Extend field rest) with (Field.progress field)\n progress (Extend field rest) | (Done value) with (Fields.progress rest)\n progress (Extend field rest) | (Done value) | (Done values)\n = Done (Extend value values)\n progress (Extend field rest) | (Done value) | (Step step)\n = Step (SimplifyExtendRest value step)\n progress (Extend field rest) | (Step step)\n = Step (SimplifyExtendValue step)\n\n namespace Cases\n public export\n progress : {value' : Variant Nil type}\n -> (idx : Elem type kvs)\n -> (value : Value value')\n -> (term : Cases Nil kvs body)\n -> Progress value' idx term\n progress Here value (Singleton (MkCase branch))\n = Step (ReduceSingleton value)\n\n progress Here value (Extend (MkCase branch) rest)\n = Step (ReduceExtend value)\n\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 -- Body of progress from above.\n\n -- Let-Binding & 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 Value\n progress (I x) = Done I\n progress (C x) = Done C\n\n -- Variant Constructors\n progress TyInt = Done TyInt\n progress TyChar = Done TyChar\n\n progress (TyVariant fields) with (Fields.progress fields)\n progress (TyVariant fields) | (Done value) = Done (TyVariant value)\n progress (TyVariant fields) | (Step step) = Step (SimplifyTyVariant step)\n\n -- Variant Value Constructors\n progress (Tag field type chk prf) with (progress type)\n progress (Tag field type chk prf) | (Done valueT) with (progress field)\n progress (Tag field type chk prf) | (Done valueT) | (Done valueF)\n = Done (Tag valueT valueF)\n progress (Tag field type chk prf) | (Done valueT) | (Step stepF)\n = Step (SimplifyTagValue valueT stepF)\n progress (Tag field type chk prf) | (Step step)\n = Step (SimplifyTagType step)\n\n -- Variant Matching\n progress (Match field cases) with (progress field)\n progress (Match (Tag label value t idx) cases) | (Done (Tag prfT prfV)) with (Cases.progress idx prfV cases)\n progress (Match (Tag label value t idx) cases) | (Done (Tag prfT prfV)) | (Step step)\n = Step (ReduceCases prfV prfT step)\n\n progress (Match field cases) | (Step step) = Step (SimplifyMatchCase step)\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\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 -> 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}) | (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))\n = Just (Element term steps)\n run this | (RunEval steps OOF) = Nothing\n\n\nnamespace Example\n public export\n iciTy : Variant Nil (VariantTyDesc [IntTyDesc, CharTyDesc])\n iciTy = TyVariant (Extend (MkField TyInt)\n (Singleton (MkField TyChar)))\n\n\n public export\n ici : Variant Nil (VariantTy [IntTy, CharTy])\n ici = Tag (I 1) iciTy (CheckVar (CheckRest CheckInt (CheckOne CheckChar))) Here\n\n public export\n icc : Variant Nil (VariantTy [IntTy, CharTy])\n icc = Let iciTy (Tag (C 'c') (Var Here) (CheckVar (CheckRest CheckInt (CheckOne CheckChar))) (There Here))\n\n\n public export\n iciM : Variant Nil IntTy\n iciM = Match ici (Extend (MkCase (Var Here))\n (Singleton (MkCase (I 2))))\n\n public export\n iccM : Variant Nil IntTy\n iccM = Match icc (Extend (MkCase (Var Here))\n (Singleton (MkCase (I 2))))\n", "meta": {"hexsha": "5fcf17648aeb0aeb8058842aaf59e4dbc981eb50", "size": 26189, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Razor/Variant/Unique.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/Unique.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/Unique.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": 34.055916775, "max_line_length": 114, "alphanum_fraction": 0.5039520409, "num_tokens": 6022, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245953120233, "lm_q2_score": 0.6893056231680121, "lm_q1q2_score": 0.5744153294727857}}
{"text": "||| Properties of Data.Vect.map\nmodule Data.Vect.Properties.Map\n\nimport Data.Vect.Properties.Tabulate\nimport Data.Vect.Properties.Index\nimport Data.Vect.Properties.Foldr\n\nimport Data.Vect\nimport Data.Vect.Elem\nimport Data.Fin\nimport Data.Vect.Extra\n\nimport Syntax.PreorderReasoning\n\n||| `map` functoriality: identity preservation\nexport\nmapId : (xs : Vect n a) -> map Prelude.id xs = xs\nmapId xs = vectorExtensionality _ _ $ \\i => indexNaturality _ _ _\n\n||| `mapWtihPos f` represents post-composition the tabulated function `f`\nexport\nindexMapWithPos : (f : Fin n -> a -> b) -> (xs : Vect n a) -> (i : Fin n)\n -> index i (mapWithPos f xs) = f i (index i xs)\nindexMapWithPos f (x :: _ ) FZ = Refl\nindexMapWithPos f (_ :: xs) (FS i) = indexMapWithPos _ _ _\n\n||| `tabulate : (Fin n ->) -> Vect n` is a natural transformation\nexport\nmapTabulate : (f : a -> b) -> (g : Fin n -> a)\n -> tabulate (f . g) = map f (tabulate g)\nmapTabulate f g = irrelevantEq $\n vectorExtensionality _ _ $ \\i => Calc $\n |~ index i (tabulate (f . g))\n ~~ f (g i) ...(indexTabulate _ _)\n ~~ f (index i $ tabulate g) ...(cong f (sym $ indexTabulate _ _))\n ~~ index i (map f $ tabulate g) ...(sym $ indexNaturality _ _ _)\n\n||| Tabulating with the constant function is replication\nexport\ntabulateConstantly : (x : a) -> Fin.tabulate {len} (const x) === replicate len x\ntabulateConstantly x = irrelevantEq $\n vectorExtensionality _ _ $ \\i => Calc $\n |~ index i (Fin.tabulate (const x))\n ~~ x ...(indexTabulate _ _)\n ~~ index i (replicate _ x) ...(sym $ indexReplicate _ _)\n\n||| It's enough that two functions agree on the elements of a vector for the maps to agree\nexport\nmapRestrictedExtensional : (f, g : a -> b) -> (xs : Vect n a)\n -> (prf : (i : Fin n) -> f (index i xs) = g (index i xs))\n -> map f xs = map g xs\nmapRestrictedExtensional f g xs prf = vectorExtensionality _ _ $ \\i => Calc $\n |~ index i (map f xs)\n ~~ f (index i xs) ...( indexNaturality _ _ _)\n ~~ g (index i xs) ...(prf _)\n ~~ index i (map g xs) ...(sym $ indexNaturality _ _ _)\n\n||| function extensionality is a congruence wrt map\nexport\nmapExtensional : (f, g : a -> b)\n -> (prf : (x : a) -> f x = g x)\n -> (xs : Vect n a)\n -> map f xs = map g xs\nmapExtensional f g prf xs = mapRestrictedExtensional f g xs (\\i => prf (index i xs))\n\n||| map-fusion property for vectors up to function extensionality\nexport\nmapFusion : (f : b -> c) -> (g : a -> b) -> (xs : Vect n a)\n -> map f (map g xs) = map (f . g) xs\nmapFusion f g [] = Refl\nmapFusion f g (x :: xs) = cong (f $ g x ::) $ mapFusion f g xs\n\n||| function extensionality is a congruence wrt mapWithElem\nexport\nmapWithElemExtensional : (xs : Vect n a) -> (f, g : (x : a) -> (0 _ : x `Elem` xs) -> b)\n -> ((x : a) -> (0 pos : x `Elem` xs) -> f x pos = g x pos)\n -> mapWithElem xs f = mapWithElem xs g\nmapWithElemExtensional [] f g prf = Refl\nmapWithElemExtensional (x :: xs) f g prf\n = cong2 (::) (prf x Here)\n (mapWithElemExtensional xs _ _ (\\x,pos => prf x (There pos)))\n", "meta": {"hexsha": "71cd07de76c7f9aabb9b7ff77cde324aef983b8e", "size": 3057, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/contrib/Data/Vect/Properties/Map.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/Vect/Properties/Map.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/Vect/Properties/Map.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": 37.2804878049, "max_line_length": 90, "alphanum_fraction": 0.620543016, "num_tokens": 1012, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149758396752, "lm_q2_score": 0.7606506418255927, "lm_q1q2_score": 0.5742265608962007}}
{"text": "module EquivFoldConstants\n\nimport Equiv\nimport Expr\nimport Logic\nimport Imp\nimport Maps\n\n%access public export\n\n%default total\n\nfold_constants_aexp : (a : AExp) -> AExp\nfold_constants_aexp (ANum k) = ANum k\nfold_constants_aexp (AId x) = AId x\nfold_constants_aexp (APlus a1 a2) =\n case (fold_constants_aexp a1, fold_constants_aexp a2) of\n (ANum n1, ANum n2) => ANum (n1 + n2)\n (e1, e2) => APlus e1 e2\nfold_constants_aexp (AMinus a1 a2) =\n case (fold_constants_aexp a1, fold_constants_aexp a2) of\n (ANum n1, ANum n2) => ANum (minus n1 n2)\n (e1, e2) => AMinus e1 e2\nfold_constants_aexp (AMult a1 a2) =\n case (fold_constants_aexp a1, fold_constants_aexp a2) of\n (ANum n1, ANum n2) => ANum (n1 * n2)\n (e1, e2) => AMult e1 e2\n\nfold_aexp_example_1 : fold_constants_aexp ((1 + 2) * X) = 3 * X\nfold_aexp_example_1 = Refl\n\nfold_aexp_example_2 : fold_constants_aexp (X - (0 * 6 + Y))\n = X - (0 + Y)\nfold_aexp_example_2 = Refl\n\nfold_constants_bexp : (b : BExp) -> BExp\nfold_constants_bexp BTrue = BTrue\nfold_constants_bexp BFalse = BFalse\nfold_constants_bexp (BEq a1 a2) =\n case (fold_constants_aexp a1, fold_constants_aexp a2) of\n (ANum n1, ANum n2) => if n1 == n2 then BTrue else BFalse\n (e1, e2) => BEq e1 e2\nfold_constants_bexp (BLe a1 a2) =\n case (fold_constants_aexp a1, fold_constants_aexp a2) of\n (ANum n1, ANum n2) => if lte n1 n2 then BTrue else BFalse\n (e1, e2) => BLe e1 e2\nfold_constants_bexp (BNot b) =\n case fold_constants_bexp b of\n BTrue => BFalse\n BFalse => BTrue\n e => BNot e\nfold_constants_bexp (BAnd b1 b2) =\n case (fold_constants_bexp b1, fold_constants_bexp b2) of\n (BTrue, e2) => e2\n (BFalse, _) => BFalse\n (e1, e2) => BAnd e1 e2\n\nfold_bexp_example_1 : fold_constants_bexp (BTrue && (not (BFalse && BTrue)))\n = BTrue\nfold_bexp_example_1 = Refl\n\nfold_bexp_example_2 : fold_constants_bexp ((X == Y) && (0 == 2 - (1 + 1)))\n = (X == Y) && BTrue\nfold_bexp_example_2 = Refl\n\nfold_constants_com : (c : Com) -> Com\nfold_constants_com CSkip = SKIP\nfold_constants_com (CAss x e) = x ::= fold_constants_aexp e\nfold_constants_com (CSeq c1 c2) = CSeq (fold_constants_com c1)\n (fold_constants_com c2)\nfold_constants_com (CIf b ct cf) =\n case fold_constants_bexp b of\n BTrue => fold_constants_com ct\n BFalse => fold_constants_com cf\n e => CIf e (fold_constants_com ct) (fold_constants_com cf)\nfold_constants_com (CIf1 b c) =\n case fold_constants_bexp b of\n BTrue => fold_constants_com c\n BFalse => SKIP\n e => CIf1 e (fold_constants_com c)\nfold_constants_com (CWhile b c) =\n case fold_constants_bexp b of\n BTrue => CWhile BTrue SKIP\n BFalse => SKIP\n e => CWhile e (fold_constants_com c)\nfold_constants_com (CFor init cond updt body) =\n case fold_constants_bexp cond of\n BTrue => CSeq (fold_constants_com init) (CWhile BTrue SKIP)\n BFalse => fold_constants_com init\n e => CFor (fold_constants_com init)\n e\n (fold_constants_com updt)\n (fold_constants_com body)\nfold_constants_com (CRepeat c b) =\n case fold_constants_bexp b of\n BTrue => fold_constants_com c\n BFalse => CSeq (fold_constants_com c) (CWhile BTrue SKIP)\n e => CRepeat (fold_constants_com c) e\n\nfold_com_example_1 :\n fold_constants_com\n (do X ::= 4 + 5\n Y ::= X - 3\n IFB X - Y == 2 + 4\n THEN SKIP\n ELSE Y ::= 0\n FI\n IFB 0 <= 4 - (2 + 1)\n THEN Y ::= 0\n ELSE SKIP\n FI\n WHILE (Y == 0) $\n X ::= X + 1)\n = (do X ::= 9\n Y ::= X - 3\n IFB X - Y == 6\n THEN SKIP\n ELSE Y ::= 0\n FI\n Y ::= 0\n WHILE (Y == 0) $\n X ::= X + 1)\nfold_com_example_1 = Refl\n\nfold_constants_aexp_sound : ATransSound EquivFoldConstants.fold_constants_aexp\nfold_constants_aexp_sound (ANum _) _ = Refl\nfold_constants_aexp_sound (AId _) _ = Refl\nfold_constants_aexp_sound (APlus a1 a2) st\n with (fold_constants_aexp a1) proof a1prf\n fold_constants_aexp_sound (APlus a1 a2) st | ANum _\n with (fold_constants_aexp a2) proof a2prf\n fold_constants_aexp_sound (APlus a1 a2) st | ANum _ | ANum _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (APlus a1 a2) st | ANum _ | AId _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (APlus a1 a2) st | ANum _ | APlus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (APlus a1 a2) st | ANum _ | AMinus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (APlus a1 a2) st | ANum _ | AMult _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (APlus a1 a2) st | AId _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_aexp_sound (APlus a1 a2) st | APlus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_aexp_sound (APlus a1 a2) st | AMinus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_aexp_sound (APlus a1 a2) st | AMult _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\nfold_constants_aexp_sound (AMinus a1 a2) st\n with (fold_constants_aexp a1) proof a1prf\n fold_constants_aexp_sound (AMinus a1 a2) st | ANum _\n with (fold_constants_aexp a2) proof a2prf\n fold_constants_aexp_sound (AMinus a1 a2) st | ANum _ | ANum _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (AMinus a1 a2) st | ANum _ | AId _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (AMinus a1 a2) st | ANum _ | APlus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (AMinus a1 a2) st | ANum _ | AMinus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (AMinus a1 a2) st | ANum _ | AMult _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (AMinus a1 a2) st | AId _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_aexp_sound (AMinus a1 a2) st | APlus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_aexp_sound (AMinus a1 a2) st | AMinus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_aexp_sound (AMinus a1 a2) st | AMult _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\nfold_constants_aexp_sound (AMult a1 a2) st\n with (fold_constants_aexp a1) proof a1prf\n fold_constants_aexp_sound (AMult a1 a2) st | ANum _\n with (fold_constants_aexp a2) proof a2prf\n fold_constants_aexp_sound (AMult a1 a2) st | ANum _ | ANum _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (AMult a1 a2) st | ANum _ | AId _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (AMult a1 a2) st | ANum _ | APlus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (AMult a1 a2) st | ANum _ | AMinus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (AMult a1 a2) st | ANum _ | AMult _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_aexp_sound (AMult a1 a2) st | AId _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_aexp_sound (AMult a1 a2) st | APlus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_aexp_sound (AMult a1 a2) st | AMinus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_aexp_sound (AMult a1 a2) st | AMult _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n\nfold_constants_bexp_sound : BTransSound EquivFoldConstants.fold_constants_bexp\nfold_constants_bexp_sound BTrue _ = Refl\nfold_constants_bexp_sound BFalse _ = Refl\nfold_constants_bexp_sound (BEq a1 a2) st\n with (fold_constants_aexp a1) proof a1prf\n fold_constants_bexp_sound (BEq a1 a2) st | ANum k\n with (fold_constants_aexp a2) proof a2prf\n fold_constants_bexp_sound (BEq a1 a2) st | ANum k | ANum j\n with (k == j) proof eprf\n fold_constants_bexp_sound (BEq a1 a2) st | ANum k | ANum j | False =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in rewrite sym eprf\n in Refl\n fold_constants_bexp_sound (BEq a1 a2) st | ANum k | ANum j | True =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in rewrite sym eprf\n in Refl\n fold_constants_bexp_sound (BEq a1 a2) st | ANum _ | AId _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_bexp_sound (BEq a1 a2) st | ANum _ | APlus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_bexp_sound (BEq a1 a2) st | ANum _ | AMinus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_bexp_sound (BEq a1 a2) st | ANum _ | AMult _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_bexp_sound (BEq a1 a2) st | AId _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_bexp_sound (BEq a1 a2) st | APlus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_bexp_sound (BEq a1 a2) st | AMinus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_bexp_sound (BEq a1 a2) st | AMult _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\nfold_constants_bexp_sound (BLe a1 a2) st\n with (fold_constants_aexp a1) proof a1prf\n fold_constants_bexp_sound (BLe a1 a2) st | ANum k\n with (fold_constants_aexp a2) proof a2prf\n fold_constants_bexp_sound (BLe a1 a2) st | ANum k | ANum j\n with (lte k j) proof lte_prf\n fold_constants_bexp_sound (BLe a1 a2) st | ANum k | ANum j | False =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in rewrite lte_prf\n in Refl\n fold_constants_bexp_sound (BLe a1 a2) st | ANum k | ANum j | True =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in rewrite lte_prf\n in Refl\n fold_constants_bexp_sound (BLe a1 a2) st | ANum _ | AId _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_bexp_sound (BLe a1 a2) st | ANum _ | APlus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_bexp_sound (BLe a1 a2) st | ANum _ | AMinus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_bexp_sound (BLe a1 a2) st | ANum _ | AMult _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in rewrite sym a2prf\n in Refl\n fold_constants_bexp_sound (BLe a1 a2) st | AId _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_bexp_sound (BLe a1 a2) st | APlus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_bexp_sound (BLe a1 a2) st | AMinus _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\n fold_constants_bexp_sound (BLe a1 a2) st | AMult _ _ =\n rewrite fold_constants_aexp_sound a1 st\n in rewrite sym a1prf\n in rewrite fold_constants_aexp_sound a2 st\n in Refl\nfold_constants_bexp_sound (BNot b) st\n with (fold_constants_bexp b) proof bprf\n fold_constants_bexp_sound (BNot b) st | BTrue =\n rewrite fold_constants_bexp_sound b st\n in rewrite sym bprf\n in Refl\n fold_constants_bexp_sound (BNot b) st | BFalse =\n rewrite fold_constants_bexp_sound b st\n in rewrite sym bprf\n in Refl\n fold_constants_bexp_sound (BNot b) st | BEq _ _ =\n rewrite fold_constants_bexp_sound b st\n in rewrite sym bprf\n in Refl\n fold_constants_bexp_sound (BNot b) st | BLe _ _ =\n rewrite fold_constants_bexp_sound b st\n in rewrite sym bprf\n in Refl\n fold_constants_bexp_sound (BNot b) st | BNot _ =\n rewrite fold_constants_bexp_sound b st\n in rewrite sym bprf\n in Refl\n fold_constants_bexp_sound (BNot b) st | BAnd _ _ =\n rewrite fold_constants_bexp_sound b st\n in rewrite sym bprf\n in Refl\nfold_constants_bexp_sound (BAnd b1 b2) st\n with (fold_constants_bexp b1) proof b1prf\n fold_constants_bexp_sound (BAnd b1 b2) st | BTrue =\n rewrite fold_constants_bexp_sound b1 st\n in rewrite sym b1prf\n in fold_constants_bexp_sound b2 st\n fold_constants_bexp_sound (BAnd b1 b2) st | BFalse =\n rewrite fold_constants_bexp_sound b1 st\n in rewrite sym b1prf\n in Refl\n fold_constants_bexp_sound (BAnd b1 b2) st | BEq _ _ =\n rewrite fold_constants_bexp_sound b1 st\n in rewrite sym b1prf\n in rewrite fold_constants_bexp_sound b2 st\n in Refl\n fold_constants_bexp_sound (BAnd b1 b2) st | BLe _ _ =\n rewrite fold_constants_bexp_sound b1 st\n in rewrite sym b1prf\n in rewrite fold_constants_bexp_sound b2 st\n in Refl\n fold_constants_bexp_sound (BAnd b1 b2) st | BNot _ =\n rewrite fold_constants_bexp_sound b1 st\n in rewrite sym b1prf\n in rewrite fold_constants_bexp_sound b2 st\n in Refl\n fold_constants_bexp_sound (BAnd b1 b2) st | BAnd _ _ =\n rewrite fold_constants_bexp_sound b1 st\n in rewrite sym b1prf\n in rewrite fold_constants_bexp_sound b2 st\n in Refl\n\nfold_constants_com_sound : CTransSound EquivFoldConstants.fold_constants_com\nfold_constants_com_sound CSkip st st' = refl_cequiv {c=CSkip} st st'\nfold_constants_com_sound (CAss x e) st st' =\n let c_equiv = cAss_congruence (fold_constants_aexp_sound e)\n in c_equiv st st'\nfold_constants_com_sound (CSeq c1 c2) st st' =\n let c_equiv = cSeq_congruence (fold_constants_com_sound c1)\n (fold_constants_com_sound c2)\n in c_equiv st st'\nfold_constants_com_sound (CIf b ct cf) st st'\n with (fold_constants_bexp b) proof bprf\n fold_constants_com_sound (CIf b ct cf) st st' | BTrue =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n in trans_cequiv (test_true b_equiv) (fold_constants_com_sound ct) st st'\n fold_constants_com_sound (CIf b ct cf) st st' | BFalse =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n in trans_cequiv (test_false b_equiv) (fold_constants_com_sound cf) st st'\n fold_constants_com_sound (CIf b ct cf) st st' | BEq _ _ =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n ct_equiv = fold_constants_com_sound ct\n cf_equiv = fold_constants_com_sound cf\n cif_equiv = cIf_congruence b_equiv ct_equiv cf_equiv\n in cif_equiv st st'\n fold_constants_com_sound (CIf b ct cf) st st' | BLe _ _ =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n ct_equiv = fold_constants_com_sound ct\n cf_equiv = fold_constants_com_sound cf\n cif_equiv = cIf_congruence b_equiv ct_equiv cf_equiv\n in cif_equiv st st'\n fold_constants_com_sound (CIf b ct cf) st st' | BNot _ =\n let b_equiv = \\st1 =>\n replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n ct_equiv = fold_constants_com_sound ct\n cf_equiv = fold_constants_com_sound cf\n cif_equiv = cIf_congruence b_equiv ct_equiv cf_equiv\n in cif_equiv st st'\n fold_constants_com_sound (CIf b ct cf) st st' | BAnd _ _ =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n ct_equiv = fold_constants_com_sound ct\n cf_equiv = fold_constants_com_sound cf\n cif_equiv = cIf_congruence b_equiv ct_equiv cf_equiv\n in cif_equiv st st'\nfold_constants_com_sound (CIf1 b c) st st'\n with (fold_constants_bexp b) proof bprf\n fold_constants_com_sound (CIf1 b c) st st' | BTrue =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n in trans_cequiv (if1_true b_equiv) (fold_constants_com_sound c) st st'\n fold_constants_com_sound (CIf1 b c) st st' | BFalse =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n in if1_false b_equiv st st'\n fold_constants_com_sound (CIf1 b c) st st' | BEq _ _ =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n cif1_equiv = cIf1_congruence b_equiv (fold_constants_com_sound c)\n in cif1_equiv st st'\n fold_constants_com_sound (CIf1 b c) st st' | BLe _ _ =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n cif1_equiv = cIf1_congruence b_equiv (fold_constants_com_sound c)\n in cif1_equiv st st'\n fold_constants_com_sound (CIf1 b c) st st' | BNot _ =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n cif1_equiv = cIf1_congruence b_equiv (fold_constants_com_sound c)\n in cif1_equiv st st'\n fold_constants_com_sound (CIf1 b c) st st' | BAnd _ _ =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n cif1_equiv = cIf1_congruence b_equiv (fold_constants_com_sound c)\n in cif1_equiv st st'\nfold_constants_com_sound (CWhile b c) st st'\n with (fold_constants_bexp b) proof bprf\n fold_constants_cwhile_sound (CWhile b c) st st' | BTrue =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n in while_true b_equiv st st'\n fold_constants_cwhile_sound (CWhile b c) st st' | BFalse =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n in while_false b_equiv st st'\n fold_constants_cwhile_sound (CWhile b c) st st' | BEq _ _ =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n c_equiv = fold_constants_com_sound c\n while_equiv = cWhile_congruence b_equiv c_equiv\n in while_equiv st st'\n fold_constants_cwhile_sound (CWhile b c) st st' | BLe _ _ =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n c_equiv = fold_constants_com_sound c\n while_equiv = cWhile_congruence b_equiv c_equiv\n in while_equiv st st'\n fold_constants_cwhile_sound (CWhile b c) st st' | BNot _ =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n c_equiv = fold_constants_com_sound c\n while_equiv = cWhile_congruence b_equiv c_equiv\n in while_equiv st st'\n fold_constants_cwhile_sound (CWhile b c) st st' | BAnd _ _ =\n let b_equiv = \\st1 => replace {P=\\x => beval st1 b = beval st1 x}\n (sym bprf) (fold_constants_bexp_sound b st1)\n c_equiv = fold_constants_com_sound c\n while_equiv = cWhile_congruence b_equiv c_equiv\n in while_equiv st st'\nfold_constants_com_sound (CFor init cond updt body) st st'\n with (fold_constants_bexp cond) proof cond_prf\n fold_constants_com_sound (CFor init cond updt body) st st' | BTrue =\n let cond_equiv = \\st1 => cong {f=beval st1} (sym cond_prf)\n while_equiv = trans_cequiv\n (trans_cequiv\n (cFor_congruence\n {cond1=fold_constants_bexp cond} {cond2=BTrue}\n refl_cequiv cond_equiv refl_cequiv refl_cequiv)\n for_while_equiv)\n (cSeq_congruence (fold_constants_com_sound init)\n (while_true btrue_is_true))\n equiv = trans_cequiv (cFor_congruence\n refl_cequiv\n (fold_constants_bexp_sound cond)\n refl_cequiv\n refl_cequiv)\n while_equiv\n in equiv st st'\n fold_constants_com_sound (CFor init cond updt body) st st' | BFalse =\n let cond_equiv = \\st1 => cong {f=beval st1} (sym cond_prf)\n while_equiv = trans_cequiv\n (trans_cequiv\n (cFor_congruence\n {cond1=fold_constants_bexp cond} {cond2=BFalse}\n refl_cequiv cond_equiv refl_cequiv refl_cequiv)\n for_while_equiv)\n (cSeq_congruence (fold_constants_com_sound init)\n (while_false bfalse_is_false))\n equiv = trans_cequiv (cFor_congruence\n refl_cequiv\n (fold_constants_bexp_sound cond)\n refl_cequiv\n refl_cequiv)\n (trans_cequiv while_equiv skip_right)\n in equiv st st'\n fold_constants_com_sound (CFor init cond updt body) st st' | BEq _ _ =\n let cond_equiv = trans_bequiv (fold_constants_bexp_sound cond)\n (\\st1 => cong {f=beval st1} (sym cond_prf))\n equiv = cFor_congruence (fold_constants_com_sound init)\n cond_equiv\n (fold_constants_com_sound updt)\n (fold_constants_com_sound body)\n in equiv st st'\n fold_constants_com_sound (CFor init cond updt body) st st' | BLe _ _ =\n let cond_equiv = trans_bequiv (fold_constants_bexp_sound cond)\n (\\st1 => cong {f=beval st1} (sym cond_prf))\n equiv = cFor_congruence (fold_constants_com_sound init)\n cond_equiv\n (fold_constants_com_sound updt)\n (fold_constants_com_sound body)\n in equiv st st'\n fold_constants_com_sound (CFor init cond updt body) st st' | BNot _ =\n let cond_equiv = trans_bequiv (fold_constants_bexp_sound cond)\n (\\st1 => cong {f=beval st1} (sym cond_prf))\n equiv = cFor_congruence (fold_constants_com_sound init)\n cond_equiv\n (fold_constants_com_sound updt)\n (fold_constants_com_sound body)\n in equiv st st'\n fold_constants_com_sound (CFor init cond updt body) st st' | BAnd _ _ =\n let cond_equiv = trans_bequiv (fold_constants_bexp_sound cond)\n (\\st1 => cong {f=beval st1} (sym cond_prf))\n equiv = cFor_congruence (fold_constants_com_sound init)\n cond_equiv\n (fold_constants_com_sound updt)\n (fold_constants_com_sound body)\n in equiv st st'\nfold_constants_com_sound (CRepeat body cond) st st'\n with (fold_constants_bexp cond) proof cond_prf\n fold_constants_com_sound (CRepeat body cond) st st' | BTrue =\n let cond_equiv = trans_bequiv\n (fold_constants_bexp_sound cond)\n (\\st1 => cong {f=beval st1} (sym cond_prf))\n while_equiv = trans_cequiv\n (cRepeat_congruence (fold_constants_com_sound body)\n cond_equiv)\n (trans_cequiv\n repeat_while_equiv\n (cSeq_congruence\n refl_cequiv\n (while_false bnot_btrue_is_bfalse)))\n equiv = trans_cequiv while_equiv skip_right\n in equiv st st'\n fold_constants_com_sound (CRepeat body cond) st st' | BFalse =\n let cond_equiv = trans_bequiv\n (fold_constants_bexp_sound cond)\n (\\st1 => cong {f=beval st1} (sym cond_prf))\n equiv = trans_cequiv\n (cRepeat_congruence (fold_constants_com_sound body)\n cond_equiv)\n (trans_cequiv\n repeat_while_equiv\n (cSeq_congruence\n refl_cequiv\n (while_true bnot_bfalse_is_btrue)))\n in equiv st st'\n fold_constants_com_sound (CRepeat body cond) st st' | BEq _ _ =\n let cond_equiv = trans_bequiv (fold_constants_bexp_sound cond)\n (\\st1 => cong {f=beval st1} (sym cond_prf))\n equiv = cRepeat_congruence (fold_constants_com_sound body) cond_equiv\n in equiv st st'\n fold_constants_com_sound (CRepeat body cond) st st' | BLe _ _ =\n let cond_equiv = trans_bequiv (fold_constants_bexp_sound cond)\n (\\st1 => cong {f=beval st1} (sym cond_prf))\n equiv = cRepeat_congruence (fold_constants_com_sound body) cond_equiv\n in equiv st st'\n fold_constants_com_sound (CRepeat body cond) st st' | BNot _ =\n let cond_equiv = trans_bequiv (fold_constants_bexp_sound cond)\n (\\st1 => cong {f=beval st1} (sym cond_prf))\n equiv = cRepeat_congruence (fold_constants_com_sound body) cond_equiv\n in equiv st st'\n fold_constants_com_sound (CRepeat body cond) st st' | BAnd _ _ =\n let cond_equiv = trans_bequiv (fold_constants_bexp_sound cond)\n (\\st1 => cong {f=beval st1} (sym cond_prf))\n equiv = cRepeat_congruence (fold_constants_com_sound body) cond_equiv\n in equiv st st'\n", "meta": {"hexsha": "9362e02a106514e3108ea02978b4807a0d9f1d1d", "size": 31714, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "EquivFoldConstants.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": "EquivFoldConstants.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": "EquivFoldConstants.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": 44.7937853107, "max_line_length": 80, "alphanum_fraction": 0.6248975216, "num_tokens": 8778, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389817407016, "lm_q2_score": 0.7690802370707283, "lm_q1q2_score": 0.5738407449648506}}
{"text": "import VISD.Common\n\n-- List Bool <-> Nat, with size and endianness\n\ndata Endianness = BE | LE\n\nsnoc : {n : Nat} -> {a : Type} -> (x : a) -> Vect n a -> Vect (S n) a\nsnoc x [] = [x]\nsnoc x (y :: xs) = (y :: snoc x xs)\n\nreverse : {n : Nat} -> Vect n a -> Vect n a\nreverse [] = []\nreverse (x :: xs) = (snoc x (reverse xs))\n\nreverse_snoc : {a : Type} -> {n : Nat} -> (x : a) -> (v : Vect n a) -> reverse (snoc x v) = x :: reverse v\nreverse_snoc x [] = Refl\nreverse_snoc x (y :: xs) = rewrite (reverse_snoc x xs) in Refl\n\ndouble_reverse : (v : Vect n a) -> reverse (reverse v) = v\ndouble_reverse [] = Refl\ndouble_reverse (x :: xs) = rewrite (reverse_snoc x (reverse xs)) in\n rewrite (double_reverse xs) in Refl\n\norder : Endianness -> Vect n Bool -> Vect n Bool\norder BE v = reverse v\norder LE v = v\n\ndouble_order : (e : Endianness) -> (v : Vect n Bool) -> order e (order e v) = v\ndouble_order BE v = (double_reverse v)\ndouble_order LE v = Refl\n\ndiv2 : Nat -> Nat\ndiv2 Z = 0\ndiv2 (S Z) = 0\ndiv2 (S (S k)) = div2' (S k)\n where -- a hack for totality checker\n div2' : Nat -> Nat\n div2' Z = 0\n div2' (S n) = S (div2 n)\n\ndiv2_zero : (k : Nat) -> (lte k (S Z) = True) -> div2 k = Z\ndiv2_zero Z prf = Refl\ndiv2_zero (S Z) prf = Refl\ndiv2_zero (S (S k)) prf = (void (trueNotFalse (sym prf)))\n\nmul2 : Nat -> Nat\nmul2 Z = 0\nmul2 (S k) = (S (S (mul2 k)))\n\nmul2_n_zero : (n : Nat) -> (mul2 n = Z) -> n = Z\nmul2_n_zero Z prf = Refl\nmul2_n_zero (S k) prf = void $ OnotS (sym prf)\n\nmul2_zero_n : (n : Nat) -> n = Z -> mul2 n = Z\nmul2_zero_n n prf = rewrite prf in Refl\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\neven_inv : (n : Nat) -> (even (S n) = not (even n))\neven_inv Z = Refl\neven_inv (S Z) = Refl\neven_inv (S (S k)) = (even_inv k)\n\nmul2_even : (n : Nat) -> even (mul2 n) = True\nmul2_even Z = Refl\nmul2_even (S k) = (mul2_even k)\n\nmul2_not_odd : (n : Nat) -> odd (mul2 n) = False\nmul2_not_odd Z = Refl\nmul2_not_odd (S k) = (mul2_not_odd k)\n\ndiv2_mul2_n_eq_n : (n : Nat) -> div2 (mul2 n) = n\ndiv2_mul2_n_eq_n Z = Refl\ndiv2_mul2_n_eq_n (S k) = cong {f=S} $ div2_mul2_n_eq_n k\n\ndiv2_S_mul2_n_eq_n : (n : Nat) -> div2 (S (mul2 n)) = n\ndiv2_S_mul2_n_eq_n Z = Refl\ndiv2_S_mul2_n_eq_n (S k) = cong {f=S} $ div2_S_mul2_n_eq_n k\n\nmul2_div2_even : (n : Nat) -> (even n = True) -> mul2 (div2 n) = n\nmul2_div2_even Z prf = Refl\nmul2_div2_even (S Z) prf = (void (trueNotFalse (sym prf)))\nmul2_div2_even (S (S k)) prf = cong {f=S} $ cong {f=S} (mul2_div2_even k prf)\n\nmul2_div2_eq : (n, m : Nat) -> (even m = True) -> (n = div2 m) -> mul2 n = m\nmul2_div2_eq n m evp eqp = rewrite eqp in (mul2_div2_even m evp)\n\ndiv2_S_even : (n : Nat) -> (even n = True) -> div2 (S n) = div2 n\ndiv2_S_even Z prf = Refl\ndiv2_S_even (S Z) prf = (void (trueNotFalse (sym prf)))\ndiv2_S_even (S (S k)) prf = cong {f=S} (div2_S_even k prf)\n\n\n\nnatToBitsLe : (k : Nat) -> Nat -> Maybe (Vect k Bool)\nnatToBitsLe bits Z = Just $ replicate bits False\nnatToBitsLe Z n = Nothing\nnatToBitsLe (S bits) n = do\n next <- natToBitsLe bits (div2 n)\n return $ odd n :: next\n\nbitsToNatLe : Vect k Bool -> Nat\nbitsToNatLe [] = Z\nbitsToNatLe (v :: l) = (if v then 1 else 0) + (mul2 $ bitsToNatLe l)\n\n\n\nbtnl_zero_step : (xs : Vect k Bool) -> (bitsToNatLe (False :: xs) = Z) -> bitsToNatLe xs = Z\nbtnl_zero_step xs prf = mul2_n_zero (bitsToNatLe xs) $\n replace {P=(\\x => 0 + x = Z)} (plusZeroLeftNeutral (mul2 $ bitsToNatLe xs)) prf\n\nbtnl_zero : (n : Nat) -> (v : Vect n Bool) -> bitsToNatLe v = Z -> v = Vect.replicate n False\nbtnl_zero Z [] prf = Refl\nbtnl_zero (S k) (False :: xs) prf = cong {f=((Vect.(::)) False)} (btnl_zero k xs (btnl_zero_step xs prf))\nbtnl_zero (S k) (True :: xs) prf = (void $ OnotS (sym prf))\n\nntbl_zero : (x : Nat) -> (xs : Vect x Bool) -> natToBitsLe x Z = Just xs -> xs = Vect.replicate x False\nntbl_zero Z [] prf = Refl\nntbl_zero (S n) (y :: xs) prf = \n rewrite (justInjective (replace {P=(\\z => z = Just (y :: xs))} (ntbl_zero' (S n)) prf)) in Refl\n where\n ntbl_zero' : (x : Nat) -> natToBitsLe x Z = Just $ Vect.replicate x False\n ntbl_zero' x = Refl\n\nntbl_step_false : (n : Nat) -> (xs : Vect n Bool) ->\n natToBitsLe n (bitsToNatLe xs) = Just xs ->\n natToBitsLe (S n) (mul2 (bitsToNatLe xs)) = Just (False :: xs)\nntbl_step_false x xs prf with (bitsToNatLe xs)\n | Z = rewrite (ntbl_zero x xs prf) in Refl\n | S m = rewrite (div2_mul2_n_eq_n (S m)) in\n rewrite prf in\n rewrite (mul2_not_odd m) in Refl\n\nntbl_step_true : (n : Nat) -> (xs : Vect n Bool) ->\n natToBitsLe n (bitsToNatLe xs) = Just xs ->\n natToBitsLe (S n) (S (mul2 (bitsToNatLe xs))) = Just (True :: xs) \nntbl_step_true n xs prf = rewrite (mul2_even (bitsToNatLe xs)) in\n rewrite (div2_S_mul2_n_eq_n (bitsToNatLe xs)) in\n rewrite prf in Refl\n\nntbl_btnl : (k : Nat) -> (v : Vect k Bool) -> natToBitsLe k (bitsToNatLe v) = Just v\nntbl_btnl Z [] = Refl\nntbl_btnl (S n) (x :: xs) with (inspect $ bitsToNatLe xs)\n | match Z {eq=eq} = rewrite eq in\n rewrite (btnl_zero n xs eq) in case (inspect x) of\n match True {eq=eq1} => rewrite eq1 in Refl\n match False {eq=eq1} => rewrite eq1 in Refl\n | match (S m) {eq=eq} = case (inspect x) of\n match True {eq=eq1} => rewrite eq1 in (ntbl_step_true n xs (ntbl_btnl n xs))\n match False {eq=eq1} => rewrite eq1 in (ntbl_step_false n xs (ntbl_btnl n xs))\n\n\nbtnl_rep_false : (k : Nat) -> bitsToNatLe (replicate k False) = Z\nbtnl_rep_false Z = Refl\nbtnl_rep_false (S k) = (mul2_zero_n (bitsToNatLe (replicate k False)) (btnl_rep_false k))\n\n\nbtnl_ntbl : (k, n : Nat) -> maybe () (\\x => bitsToNatLe x = n) $ natToBitsLe k n\nbtnl_ntbl k Z = (btnl_rep_false k)\nbtnl_ntbl Z (S j) = ()\nbtnl_ntbl (S k) (S j) with (inspect $ natToBitsLe k (div2 (S j)))\n | match Nothing {eq=eq} = rewrite eq in ()\n | match (Just xs) {eq=eq} = rewrite eq in case (inspect $ even j) of\n match True {eq=eq1} => rewrite eq1 in cong {f=S} $ \n mul2_div2_eq (bitsToNatLe xs) j eq1 $ \n replace {P=(\\p => maybe () (\\x => bitsToNatLe x = div2 j) p)}\n (replace {P=(\\p => natToBitsLe k p = Just xs)} (div2_S_even j eq1) eq)\n (btnl_ntbl k (div2 j))\n match False {eq=eq1} => rewrite eq1 in\n mul2_div2_eq (bitsToNatLe xs) (S j) (replace {P=(\\p => even (S j) = not p)} eq1 (even_inv j)) $\n replace {P=(\\p => maybe () ((\\x => bitsToNatLe x = div2 (S j))) p)} eq (btnl_ntbl k (div2 $ S j))\n\njust_btnl_ntbl : (k, n : Nat) -> maybe () (\\x => Just (bitsToNatLe x) = Just n) $ natToBitsLe k n\njust_btnl_ntbl k n with (inspect $ natToBitsLe k n)\n | match Nothing {eq=eq} = rewrite eq in ()\n | match (Just v) {eq=eq} = rewrite eq in cong {f=Just} $ case (btnl_ntbl k n) of\n wojust => replace eq wojust\n\n\nnatLeIso : (k : Nat) -> PartIso (Vect k Bool) Nat\nnatLeIso k = MkPartIso (Just . bitsToNatLe) (natToBitsLe k) tf ft\n where\n tf n = just_btnl_ntbl k n\n ft v = ntbl_btnl k v\n\n\nnatLe : Syntax d Bool => (k : Nat) -> d Nat Bool\nnatLe k = natLeIso k <$> rep k item\n\nnatToBits : Endianness -> (k : Nat) -> Nat -> Maybe (Vect k Bool)\nnatToBits e k n = natToBitsLe k n >>= Just . order e\n\nbitsToNat : Endianness -> Vect n Bool -> Maybe Nat\nbitsToNat e v = Just $ bitsToNatLe (order e v)\n\nbtn_ntb : (k, n : Nat) -> (e : Endianness) -> maybe () (\\x => bitsToNat e x = Just n) $ natToBits e k n\nbtn_ntb k n e with (inspect $ natToBitsLe k n)\n | match Nothing {eq=eq} = rewrite eq in ()\n | match (Just as) {eq=eq} = rewrite eq in rewrite (double_order e as) in\n cong {f=Just} (replace eq {P=(\\y => maybe () (\\x => bitsToNatLe x = n) y)} (btnl_ntbl k n))\n\nntb_btn : (k : Nat) -> (e : Endianness) -> (v : Vect k Bool) ->\n maybe () (\\x => natToBits e k x = Just v) $ bitsToNat e v\nntb_btn k e v = rewrite (ntbl_btnl k (order e v)) in rewrite (double_order e v) in Refl\n\n\nnatIso : (e : Endianness) -> (k : Nat) -> PartIso (Vect k Bool) Nat\nnatIso e k = MkPartIso (bitsToNat e) (natToBits e k) tf ft\n where\n tf n = (btn_ntb k n e)\n ft v = (ntb_btn k e v)\n\nnat : Syntax d Bool => Endianness -> Nat -> d Nat Bool\nnat endianness size = natIso endianness size <$> rep size item\n", "meta": {"hexsha": "fddafdce1a332671d7ba4ee30c52087e70df8283", "size": 8110, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/VISD/Binary.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": "src/VISD/Binary.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": "src/VISD/Binary.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": 36.5315315315, "max_line_length": 106, "alphanum_fraction": 0.616892725, "num_tokens": 3108, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056322076481139, "lm_q2_score": 0.7122321781307375, "lm_q1q2_score": 0.5737971820254908}}
{"text": "module VecTk\n\nimport Data.Vect\nimport Data.Fin\n\ntk : (k : Nat) -> Vect (k + n) a -> Vect n a\ntk Z xs = xs\ntk (S k) (x::xs) = tk k xs\n", "meta": {"hexsha": "adb5e1f1b75c7408a0af69d09b8f88073a7959c0", "size": 133, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "VecTk.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": "VecTk.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": "VecTk.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": 14.7777777778, "max_line_length": 44, "alphanum_fraction": 0.5714285714, "num_tokens": 55, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8807970904940926, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.573711469677034}}
{"text": "import Data.Vect\n\nmyReverse : Vect n elem -> Vect n elem\nmyReverse [] = []\nmyReverse (x :: xs) = reverseProof (myReverse xs ++ [x]) where\n reverseProof : Vect (len + 1) elem -> Vect (S len) elem\n reverseProof result = rewrite plusCommutative 1 len in result", "meta": {"hexsha": "ad10207e96d66c2e4dfa6bac6db9dd1e87828777", "size": 299, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/ch8/ReverseVec.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/ch8/ReverseVec.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/ch8/ReverseVec.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": 42.7142857143, "max_line_length": 83, "alphanum_fraction": 0.5986622074, "num_tokens": 76, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8856314677809303, "lm_q2_score": 0.6477982179521102, "lm_q1q2_score": 0.5737104865907984}}
{"text": "module Main\n\nimport Data.List\n\n%default total\n\ndata RegExp: Type -> Type where\n Atom: a -> RegExp a\n Disj: RegExp a -> RegExp a -> RegExp a\n Seq: RegExp a -> RegExp a -> RegExp a\n Star: RegExp a -> RegExp a\n Empty: RegExp a\n Nothing: RegExp a\n\ndata RegExpSpec: RegExp a -> List a -> Type where\n AtomSpec: (x : a) -> RegExpSpec (Atom x) [x]\n DisjSpec1: (r1 : RegExp a) ->\n (r2: RegExp a) -> (xs : List a) ->\n (RegExpSpec r1 xs) ->\n RegExpSpec (Disj r1 r2) xs\n DisjSpec2: (r1 : RegExp a) ->\n (r2: RegExp a) -> (xs : List a) ->\n (RegExpSpec r2 xs) ->\n RegExpSpec (Disj r1 r2) xs\n SeqSpec: (xs : List a) -> (ys : List a) -> (zs : List a) ->\n (r1 : RegExp a) -> (r2 : RegExp a) ->\n RegExpSpec r1 xs ->\n RegExpSpec r2 ys ->\n zs = xs ++ ys ->\n RegExpSpec (Seq r1 r2) zs\n StarSpec0: (r: RegExp a) ->\n RegExpSpec (Star r) []\n StarSpecS: (xs : List a) -> (ys : List a) ->\n (zs : List a) ->\n (r : RegExp a) ->\n RegExpSpec r xs ->\n RegExpSpec (Star r) ys ->\n (zs = xs ++ ys) ->\n RegExpSpec (Star r) zs\n EmptySpec: RegExpSpec Empty []\n\nisEmpty : RegExp a -> RegExp a\nisEmpty (Atom x) = Nothing\nisEmpty (Disj x y) = Disj (isEmpty x) (isEmpty y)\nisEmpty (Seq x y) = Seq (isEmpty x) (isEmpty y)\nisEmpty (Star x) = Empty\nisEmpty Empty = Empty\nisEmpty Nothing = Nothing\n\natom_case : (x : a) -> RegExpSpec (Atom x) [] -> Void\natom_case _ _ impossible\n\ndisj_case : (x: RegExp a) -> (y: RegExp a) ->\n (contra1: RegExpSpec x [] -> Void) ->\n (contra2: RegExpSpec y [] -> Void) ->\n RegExpSpec (Disj x y) [] -> Void\ndisj_case x y contra1 contra2 (DisjSpec1 x y [] z) = contra1 z\ndisj_case x y contra1 contra2 (DisjSpec2 x y [] z) = contra2 z\n\nseq_yes_case : (x : RegExp a) -> (y : RegExp a) ->\n RegExpSpec x [] -> RegExpSpec y [] ->\n RegExpSpec (Seq x y) []\nseq_yes_case x y prf1 prf2 = SeqSpec [] [] [] x y prf1 prf2 Refl\n\nabout_list1 : (xs : List a) -> (ys : List a) ->\n [] = xs ++ ys -> [] = xs\nabout_list1 [] ys prf = Refl\nabout_list1 (_ :: _) _ Refl impossible\n\nabout_list2 : (xs : List a) -> (ys : List a) ->\n [] = xs ++ ys -> [] = ys\nabout_list2 [] [] Refl = Refl\nabout_list2 (_ :: _) _ Refl impossible\n\nabout_list3 : (x : a) -> (y : a) -> (xs : List a) ->\n (ys : List a) -> (zs : List a) -> x :: xs = (y :: ys) ++ zs ->\n (x = y, xs = ys ++ zs)\nabout_list3 y y (ys ++ zs) ys zs Refl = (Refl, Refl)\n\nabout_list4 : (x : a) -> (xs : List a) -> (ys : List a) ->\n (zs : List a) -> x :: xs = ys ++ zs ->\n Either (DPair (List a) (\\ys' => (ys = x :: ys', xs = ys' ++ zs)))\n (ys = [], zs = x :: xs)\nabout_list4 x xs [] zs prf = Right (Refl, sym prf)\nabout_list4 x xs (y :: ys) zs prf =\n let (Refl, h2) = about_list3 x y xs ys zs prf in (Left (MkDPair ys (Refl, h2)))\n\nseq_no_case1: (x : RegExp a) -> (y : RegExp a) ->\n (RegExpSpec x [] -> Void) -> RegExpSpec (Seq x y) [] -> Void\nseq_no_case1 x y f (SeqSpec xs ys [] x y z w prf) =\n let h = about_list1 xs ys prf in\n f (rewrite h in z)\n\nseq_no_case2: (x : RegExp a) -> (y : RegExp a) ->\n (RegExpSpec y [] -> Void) -> RegExpSpec (Seq x y) [] -> Void\nseq_no_case2 x y f (SeqSpec xs ys [] x y z w prf) =\n let h = about_list2 xs ys prf in\n f (rewrite h in w)\n\nmatch_nothing_is_false : (xs : List a) ->\n RegExpSpec Nothing xs -> Void\nmatch_nothing_is_false _ _ impossible\n\ndecEmpty : (r : RegExp a) -> Dec (RegExpSpec r [])\ndecEmpty (Atom x) = No (atom_case x)\ndecEmpty (Disj x y) =\n case (decEmpty x, decEmpty y) of\n (Yes prf, _) => Yes (DisjSpec1 x y [] prf)\n (_, Yes prf) => Yes (DisjSpec2 x y [] prf)\n (No contra1, No contra2) => No (disj_case x y contra1 contra2)\ndecEmpty (Seq x y) =\n case (decEmpty x, decEmpty y) of\n (Yes prf1, Yes prf2) => Yes (seq_yes_case x y prf1 prf2)\n (No contra, _) => No (seq_no_case1 x y contra)\n (_, No contra) => No (seq_no_case2 x y contra)\ndecEmpty (Star x) = Yes (StarSpec0 x)\ndecEmpty Empty = Yes EmptySpec\ndecEmpty Nothing = No (match_nothing_is_false [])\n\nderive : DecEq a => (r : RegExp a) -> (x : a) -> RegExp a\nderive (Atom y) x = case decEq y x of\n Yes _ => Empty\n No _ => Nothing\nderive (Disj y z) x = Disj (derive y x) (derive z x)\nderive (Seq y z) x = Disj (Seq (derive y x) z) (Seq (isEmpty y) (derive z x))\nderive (Star y) x = Seq (derive y x) (Star y)\nderive Empty x = Nothing\nderive Nothing x = Nothing\n\nempty_match_implies_empty_list : RegExpSpec Empty xs -> xs = []\nempty_match_implies_empty_list EmptySpec = Refl\n\nis_empty_match_implies_empty_list :\n (r : RegExp a) ->\n (xs : List a) -> RegExpSpec (isEmpty r) xs -> xs = []\nis_empty_match_implies_empty_list (Atom y) xs x =\n void (match_nothing_is_false xs x)\nis_empty_match_implies_empty_list (Disj y z) xs (DisjSpec1 (isEmpty y) (isEmpty z) xs x) =\n is_empty_match_implies_empty_list y xs x\nis_empty_match_implies_empty_list (Disj y z) xs (DisjSpec2 (isEmpty y) (isEmpty z) xs x) =\n is_empty_match_implies_empty_list z xs x\nis_empty_match_implies_empty_list (Seq y z) xs (SeqSpec ys zs xs (isEmpty y) (isEmpty z) x w prf) =\n rewrite prf in\n (let h1 = is_empty_match_implies_empty_list y ys x\n h2 = is_empty_match_implies_empty_list z zs w\n in rewrite h1 in rewrite h2 in Refl)\nis_empty_match_implies_empty_list (Star y) xs x = empty_match_implies_empty_list x\nis_empty_match_implies_empty_list Empty xs x = empty_match_implies_empty_list x\nis_empty_match_implies_empty_list Nothing xs x = void (match_nothing_is_false xs x)\n\n\nis_empty_is_sound : (r : RegExp a) -> (xs : List a) ->\n RegExpSpec (isEmpty r) xs -> RegExpSpec r []\nis_empty_is_sound (Atom y) xs x = void (match_nothing_is_false xs x)\nis_empty_is_sound (Disj y z) xs (DisjSpec1 (isEmpty y) (isEmpty z) xs x) =\n let h = is_empty_is_sound y xs x in (DisjSpec1 y z [] h)\nis_empty_is_sound (Disj y z) xs (DisjSpec2 (isEmpty y) (isEmpty z) xs x) =\n let h = is_empty_is_sound z xs x in (DisjSpec2 y z [] h)\nis_empty_is_sound (Seq y z) xs (SeqSpec ys zs xs (isEmpty y) (isEmpty z) x w prf) =\n let h1 = is_empty_is_sound y ys x in\n let h2 = is_empty_is_sound z zs w in SeqSpec [] [] [] y z h1 h2 Refl\nis_empty_is_sound (Star y) xs x = StarSpec0 y\nis_empty_is_sound Empty xs x = EmptySpec\nis_empty_is_sound Nothing xs x = void (match_nothing_is_false xs x)\n\nderivative_is_sound: DecEq a => (r : RegExp a) ->\n (x : a) -> (xs : List a) ->\n RegExpSpec (derive r x) xs -> RegExpSpec r (x :: xs)\nderivative_is_sound (Atom z) x xs y with (decEq z x)\n derivative_is_sound (Atom x) x xs y | (Yes Refl) =\n rewrite (empty_match_implies_empty_list y) in AtomSpec x\n derivative_is_sound (Atom z) x xs y | (No contra) =\n void (match_nothing_is_false xs y)\nderivative_is_sound (Disj z w) x xs y =\n case y of\n (DisjSpec1 (derive z x) _ xs y) =>\n let z' = (derivative_is_sound z x xs y)\n in DisjSpec1 z w (x :: xs) z'\n (DisjSpec2 _ (derive w x) xs y) =>\n let z' = (derivative_is_sound w x xs y)\n in DisjSpec2 z w (x :: xs) z'\nderivative_is_sound (Seq r1 r2) x xs (DisjSpec1 (Seq _ _) (Seq _ _) xs (SeqSpec ys zs xs _ r2 y z prf)) =\n let h' = derivative_is_sound r1 x ys y\n in rewrite prf in\n SeqSpec (x :: ys) zs (x :: ys ++ zs) r1 r2 h' z Refl\nderivative_is_sound (Seq r1 r2) x xs (DisjSpec2 (Seq _ r2) (Seq _ _) xs (SeqSpec ys zs xs (isEmpty r1) _ y s prf)) =\n rewrite prf in\n rewrite (is_empty_match_implies_empty_list r1 ys y) in\n let h1 = derivative_is_sound r2 x zs s in\n let h2 = is_empty_is_sound r1 ys y in\n SeqSpec [] (x :: zs) (x :: zs) r1 r2 h2 h1 Refl\nderivative_is_sound (Star z) x _ (SeqSpec xs ys zs _ (Star z) y w prf) =\n rewrite prf in\n let h = derivative_is_sound z x xs y in\n StarSpecS (x :: xs) ys (x :: xs ++ ys) z h w Refl\nderivative_is_sound Empty _ _ _ impossible\nderivative_is_sound Nothing _ _ _ impossible\n\natom_match_implies: (x : a) -> (xs : List a) ->\n RegExpSpec (Atom x) (x :: xs) -> xs = []\natom_match_implies x [] (AtomSpec x) = Refl\n\natom_match_implies2: (x : a) -> (y : a) -> (xs : List a) ->\n RegExpSpec (Atom x) (y :: xs) -> x = y\natom_match_implies2 y y [] (AtomSpec y) = Refl\n\ncons_is_not_nil : (x : a) -> (xs : List a) -> x :: xs = [] -> Void\ncons_is_not_nil _ _ Refl impossible\n\nis_empty_is_complete : (r : RegExp a) -> RegExpSpec r [] ->\n RegExpSpec (isEmpty r) []\nis_empty_is_complete (Atom _) _ impossible\nis_empty_is_complete (Disj y z) (DisjSpec1 y z [] x) =\n let h = is_empty_is_complete y x in\n DisjSpec1 (isEmpty y) (isEmpty z) [] h\nis_empty_is_complete (Disj y z) (DisjSpec2 y z [] x) =\n let h = is_empty_is_complete z x in\n DisjSpec2 (isEmpty y) (isEmpty z) [] h\nis_empty_is_complete (Seq y z) (SeqSpec xs ys [] y z x w prf) =\n let h1 = about_list1 xs ys prf in\n let h2 = about_list2 xs ys prf in\n let ih1 = is_empty_is_complete y (rewrite h1 in x) in\n let ih2 = is_empty_is_complete z (rewrite h2 in w) in\n SeqSpec [] [] [] (isEmpty y) (isEmpty z) ih1 ih2 Refl\nis_empty_is_complete (Star y) x = EmptySpec\nis_empty_is_complete Empty x = x\nis_empty_is_complete Nothing x = x\n\nappend_nil_neutral : (xs : List a) -> xs ++ [] = xs\nappend_nil_neutral [] = Refl\nappend_nil_neutral (x :: xs) =\n let h = append_nil_neutral xs in\n rewrite h in Refl\n\nabout_list5 : (x : a) -> (y : a) -> (xs : List a) -> (ys : List a) -> (zs : List a) ->\n x :: xs = (y :: ys) ++ zs -> (x = y, xs = ys ++ zs)\nabout_list5 x _ (ys ++ zs) ys zs Refl = (Refl, Refl)\n\nmutual {\nstar_case : DecEq a => (r : RegExp a) -> (x : a) ->\n (xs : List a) -> RegExpSpec (Star r) xs ->\n (xs' : List a) ->\n xs = x :: xs' ->\n RegExpSpec (Seq (derive r x) (Star r)) xs'\nstar_case r x [] (StarSpec0 r) = \\xs', contra => void (cons_is_not_nil x xs' (sym contra))\nstar_case r x _ (StarSpecS [] zs _ r y z Refl) = \\xs', Refl =>\n star_case r x (x :: xs') z xs' Refl\nstar_case r x xs (StarSpecS (w :: ys) zs xs r y z prf) = \\xs', Refl =>\n let (Refl, Refl) = about_list5 x w xs' ys zs prf in\n let h = derivative_is_complete r x ys y in\n SeqSpec ys zs (ys ++ zs) (derive r x) (Star r) h z Refl\n\nderivative_is_complete : (DecEq a) => (r : RegExp a) -> (x : a) -> (xs : List a) -> RegExpSpec r (x :: xs) -> RegExpSpec (derive r x) xs\nderivative_is_complete (Atom z) x xs y with (decEq z x)\n derivative_is_complete (Atom x) x xs y | (Yes Refl) =\n rewrite (atom_match_implies x xs y) in EmptySpec\n derivative_is_complete (Atom z) x xs y | (No contra) =\n void (contra (atom_match_implies2 z x xs y))\nderivative_is_complete (Disj z w) x xs (DisjSpec1 z w (x :: xs) y) =\n let h = derivative_is_complete z x xs y in\n DisjSpec1 (derive z x) (derive w x) xs h\nderivative_is_complete (Disj z w) x xs (DisjSpec2 z w (x :: xs) y) =\n let h = derivative_is_complete w x xs y in\n DisjSpec2 (derive z x) (derive w x) xs h\nderivative_is_complete (Seq z w) x xs (SeqSpec ys zs (x :: xs) z w y s prf) =\n case about_list4 x xs ys zs prf of\n Left (ys' ** (h1, h2)) =>\n rewrite h2 in\n let h = derivative_is_complete z x ys' (rewrite sym h1 in y) in\n DisjSpec1 (Seq (derive z x) w) (Seq (isEmpty z) (derive w x)) (ys' ++ zs)\n (SeqSpec ys' zs (ys' ++ zs) (derive z x) w h s Refl)\n Right (h1, h2) =>\n let h = derivative_is_complete w x xs (rewrite sym h2 in s) in\n DisjSpec2 (Seq (derive z x) w) (Seq (isEmpty z) (derive w x)) xs\n (SeqSpec [] xs xs (isEmpty z) (derive w x) (is_empty_is_complete z (rewrite sym h1 in y)) h Refl)\nderivative_is_complete (Star r) x xs prf =\n star_case r x (x :: xs) prf xs Refl\nderivative_is_complete Empty x xs y =\n let h = empty_match_implies_empty_list y in void (cons_is_not_nil x xs h)\nderivative_is_complete Nothing x xs y = void (match_nothing_is_false (x :: xs) y)\n}\n\nmatch : DecEq a => (xs : List a) -> (r : RegExp a) -> Dec (RegExpSpec r xs)\nmatch [] r = decEmpty r\nmatch (x :: xs) r =\n case match xs (derive r x) of\n Yes prf => Yes (derivative_is_sound r x xs prf)\n No contra => No (contra . (derivative_is_complete r x xs))\n", "meta": {"hexsha": "91516e7883ff463d3378c68264b3f67598fd4d79", "size": 12321, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "regex.idr", "max_stars_repo_name": "MathiasVP/idris-regex", "max_stars_repo_head_hexsha": "1ed5388857e81fe0c2512278eb5dfbc1dd036387", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2017-07-07T18:42:37.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-11T16:35:09.000Z", "max_issues_repo_path": "regex.idr", "max_issues_repo_name": "MathiasVP/idris-regex", "max_issues_repo_head_hexsha": "1ed5388857e81fe0c2512278eb5dfbc1dd036387", "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": "regex.idr", "max_forks_repo_name": "MathiasVP/idris-regex", "max_forks_repo_head_hexsha": "1ed5388857e81fe0c2512278eb5dfbc1dd036387", "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.6332179931, "max_line_length": 136, "alphanum_fraction": 0.6100965831, "num_tokens": 4095, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673269042767, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.5737095889469318}}
{"text": "import Control.Monad.State\n\ndata Tree a = Empty\n | Node (Tree a) a (Tree a)\n\ntestTree : Tree String\ntestTree = Node (Node (Node Empty \"Jim\" Empty) \"Fred\"\n (Node Empty \"Sheila\" Empty)) \"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 : Tree a -> State (Stream labelType) (Tree (labelType, a))\ntreeLabelWith Empty = pure Empty\ntreeLabelWith (Node left val right)\n = do left_labelled <- treeLabelWith left\n (this :: rest) <- get\n put rest\n right_labelled <- treeLabelWith right\n pure (Node left_labelled (this, val) right_labelled)\n\ntreeLabel : Tree a -> Tree (Integer, a)\ntreeLabel tree = evalState [1..] (treeLabelWith tree)\n\n", "meta": {"hexsha": "223379ce429189a9a2df2cd521d3b63c09eeadd6", "size": 847, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/typedd-book/chapter12/TreeLabelState.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/chapter12/TreeLabelState.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/chapter12/TreeLabelState.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": 31.3703703704, "max_line_length": 72, "alphanum_fraction": 0.6340023613, "num_tokens": 220, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673269042767, "lm_q2_score": 0.7057850216484838, "lm_q1q2_score": 0.5737095839164801}}
{"text": "data Tree a = Empty\n | Node (Tree a) a (Tree a)\n\ntestTree : Tree String\ntestTree = Node (Node (Node Empty \"Jim\" Empty) \"Fred\"\n (Node Empty \"Sheila\" Empty)) \"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 : Stream labelType -> Tree a ->\n (Stream labelType, Tree (labelType, a))\ntreeLabelWith lbls Empty = (lbls, Empty)\ntreeLabelWith lbls (Node left val right)\n = let (this :: lblsLeft, left_labelled) = treeLabelWith lbls left\n (lblsRight, right_labelled) = treeLabelWith lblsLeft right\n in\n (lblsRight, Node left_labelled (this, val) right_labelled)\n\ntreeLabel : Tree a -> Tree (Integer, a)\ntreeLabel tree = snd (treeLabelWith [1..] tree)\n\n", "meta": {"hexsha": "8741875a73a1f056df5fd7f10e7c149347009c1f", "size": 877, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/typedd-book/chapter12/TreeLabel.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/chapter12/TreeLabel.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/chapter12/TreeLabel.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": 35.08, "max_line_length": 70, "alphanum_fraction": 0.6259977195, "num_tokens": 236, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428946, "lm_q2_score": 0.7279754489059774, "lm_q1q2_score": 0.5735945658551598}}
{"text": "= ImpCEvalFun : Evaluation Function for Imp \n\n> module ImpCEvalFun\n\nWe saw in the `Imp` chapter how a naive approach to defining a function\nrepresenting evaluation for Imp runs into difficulties. There, we adopted the\nsolution of changing from a functional to a relational definition of evaluation.\nIn this optional chapter, we consider strategies for getting the functional\napproach to work.\n\n> import Logic\n> import Maps\n> import Imp\n\n> %access public export\n> %default total\n\n== A Broken Evaluator\n\nHere was our first try at an evaluation function for commands, omitting\n\\idr{WHILE}. \n\n> ceval_step1 : (st : State) -> (c : Com) -> State\n> ceval_step1 st CSkip = st\n> ceval_step1 st (CAss l a1) = t_update l (aeval st a1) st\n> ceval_step1 st (CSeq c1 c2) =\n> let st' = ceval_step1 st c1\n> in ceval_step1 st' c2\n> ceval_step1 st (CIf b c1 c2) =\n> if beval st b\n> then ceval_step1 st c1\n> else ceval_step1 st c2\n> ceval_step1 st (CWhile b c) = st -- bogus\n\nAs we remarked in chapter `Imp`, in a traditional functional programming\nlanguage like ML or Haskell we could write the WHILE case as follows:\n\n```idris\n...\nceval_step1 st (CWhile b c) =\n if (beval st b)\n then ceval_step1 st (CSeq c $ CWhile b c)\n else st\n```\n\nIdris doesn't accept such a definition (\\idr{ImpCEvalFun.ceval_step1 is possibly \nnot total due to recursive path ImpCEvalFun.ceval_step1 --> \nImpCEvalFun.ceval_step1 --> ImpCEvalFun.ceval_step1}) because the function we \nwant to define is not guaranteed to terminate. Indeed, the changed \n\\idr{ceval_step1} function applied to the \\idr{loop} program from `Imp.lidr` \nwould never terminate. Since Idris is not just a functional programming \nlanguage, but also a consistent logic, any potentially non-terminating function \nneeds to be rejected. Here is an invalid(!) Idris program showing what would go \nwrong if Idris allowed non-terminating recursive functions: \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 (e.g.,\n\\idr{loop_false 0} would be a proof of \\idr{Void}), which would be a disaster\nfor Idris's logical consistency.\n\nThus, because it doesn't terminate on all inputs, the full version of\n\\idr{ceval_step1} cannot be written in Idris -- at least not without one\nadditional trick... \n\n== A Step-Indexed Evaluator\n\nThe trick we need is to pass an _additional_ parameter to the evaluation\nfunction that tells it how long to run. Informally, we start the evaluator with\na certain amount of \"gas\" in its tank, and we allow it to run until either it\nterminates in the usual way _or_ it runs out of gas, at which point we simply\nstop evaluating and say that the final result is the empty memory. (We could\nalso say that the result is the current state at the point where the evaluator\nruns out fo gas -- it doesn't really matter because the result is going to be\nwrong in either case!) \n\n> ceval_step2 : (st : State) -> (c : Com) -> (i : Nat) -> State\n> ceval_step2 _ _ Z = empty_state\n> ceval_step2 st CSkip (S i') = st\n> ceval_step2 st (CAss l a1) (S i') = t_update l (aeval st a1) st\n> ceval_step2 st (CSeq c1 c2) (S i') = \n> let st' = ceval_step2 st c1 i'\n> in ceval_step2 st' c2 i'\n> ceval_step2 st (CIf b c1 c2) (S i') = \n> if beval st b\n> then ceval_step2 st c1 i'\n> else ceval_step2 st c2 i'\n> ceval_step2 st c@(CWhile b1 c1) (S i') = \n> if (beval st b1)\n> then let st' = ceval_step2 st c1 i' in \n> ceval_step2 st' c i'\n> else st\n\n_Note_: It is tempting to think that the index \\idr{i} here is counting the\n\"number of steps of evaluation.\" But if you look closely you'll see that this\nis not the case: for example, in the rule for sequencing, the same \\idr{i} is\npassed to both recursive calls. Understanding the exact way that \\idr{i} is\ntreated will be important in the proof of \\idr{ceval__ceval_step}, which is\ngiven as an exercise below.\n\nOne thing that is not so nice about this evaluator is that we can't tell, from\nits result, whether it stopped because the program terminated normally or\nbecause it ran out of gas. Our next version returns an \\idr{Maybe State}\ninstead of just a \\idr{State}, so that we can distinguish between normal and\nabnormal termination.\n\n> ceval_step3 : (st : State) -> (c : Com) -> (i : Nat) -> Maybe State\n> ceval_step3 _ _ Z = Nothing\n> ceval_step3 st CSkip (S i') = Just st\n> ceval_step3 st (CAss l a1) (S i') = Just $ t_update l (aeval st a1) st\n> ceval_step3 st (CSeq c1 c2) (S i') = \n> case ceval_step3 st c1 i' of\n> Just st' => ceval_step3 st' c2 i'\n> Nothing => Nothing\n> ceval_step3 st (CIf b c1 c2) (S i') = \n> if beval st b\n> then ceval_step3 st c1 i'\n> else ceval_step3 st c2 i'\n> ceval_step3 st c@(CWhile b1 c1) (S i') = \n> if (beval st b1)\n> then case ceval_step3 st c1 i' of \n> Just st' => ceval_step3 st' c i'\n> Nothing => Nothing\n> else Just st\n\nWe can improve the readability of this version by using the fact that /idr{Maybe} forms a monad to hide the plumbing involved in repeatedly matching against optional\nstates.\n\n```idris\nMonad Maybe where\n Nothing >>= k = Nothing\n (Just x) >>= k = k x\n```\n\n> ceval_step : (st : State) -> (c : Com) -> (i : Nat) -> Maybe State\n> ceval_step _ _ Z = Nothing\n> ceval_step st CSkip (S i') = Just st\n> ceval_step st (CAss l a1) (S i') = Just $ t_update l (aeval st a1) st\n> ceval_step st (CSeq c1 c2) (S i') = \n> do st' <- ceval_step st c1 i'\n> ceval_step st' c2 i'\n> ceval_step st (CIf b c1 c2) (S i') = \n> if beval st b\n> then ceval_step st c1 i'\n> else ceval_step st c2 i'\n> ceval_step st c@(CWhile b1 c1) (S i') = \n> if (beval st b1)\n> then do st' <- ceval_step st c1 i'\n> ceval_step st' c i'\n> else Just st\n\n> test_ceval : (st : State) -> (c : Com) -> Maybe (Nat, Nat, Nat)\n> test_ceval st c = case ceval_step st c 500 of\n> Nothing => Nothing\n> Just st => Just (st X, st Y, st Z)\n\n\\todo[inline]{Syntax sugar for IF breaks down here}\n\n```idris \nλΠ> test_ceval Imp.empty_state (CSeq (X ::= ANum 2) (CIf (BLe (AId X) (ANum 1)) (Y ::= ANum 3) (Z ::= ANum 4)))\nJust (2, 0, 4) : Maybe (Nat, Nat, Nat)\n```\n\n==== Exercise: 2 stars, recommended (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}. Make sure your solution\nsatisfies the test that follows.\n\n> pup_to_n : Com\n> pup_to_n = ?pup_to_n_rhs\n\n> pup_to_n_1 : test_ceval (t_update X 5 $ Imp.empty_state) ImpCEvalFun.pup_to_n = Just (0, 15, 0)\n> pup_to_n_1 = ?pup_to_n_1 -- replace with Refl when done\n\n$\\square$\n\n\n==== Exercise: 2 stars, optional (peven) \n\nWrite a \\idr{While} program that sets \\idr{Z} to \\idr{0} if \\idr{X} is even and\nsets \\idr{Z} to \\idr{1} otherwise. Use \\idr{test_ceval} to test your program.\n\n> -- FILL IN HERE\n\n$\\square$\n\n== Relational vs. Step-Indexed Evaluation\n\nAs for arithmetic and boolean expressions, we'd hope that the two alternative\ndefinitions of evaluation would actually amount to the same thing in the end.\nThis section shows that this is the case. \n\n> ceval_step__ceval : (c : Com) -> (st, st' : State) -> (i ** ceval_step st c i = Just st') -> c / st \\\\ st'\n> ceval_step__ceval c st st' (Z ** prf) = absurd prf\n> ceval_step__ceval CSkip st st (S i ** Refl) = E_Skip\n> ceval_step__ceval (CAss l a) st st' (S i ** prf) = \n> rewrite sym $ justInjective prf in \n> E_Ass {n=aeval st a} Refl\n> ceval_step__ceval (CSeq c1 c2) st st' (S i ** prf) with (ceval_step st c1 i) proof c1prf\n> ceval_step__ceval (CSeq c1 c2) st st' (S i ** prf) | Just st1 = \n> E_Seq (ceval_step__ceval c1 st st1 (i**sym c1prf))\n> (ceval_step__ceval c2 st1 st' (i**prf))\n> ceval_step__ceval (CSeq c1 c2) st st' (S i ** prf) | Nothing = absurd prf\n> ceval_step__ceval (CIf b c1 c2) st st' (S i ** prf) with (beval st b) proof bprf\n> ceval_step__ceval (CIf b c1 c2) st st' (S i ** prf) | True = \n> E_IfTrue (sym bprf) (ceval_step__ceval c1 st st' (i**prf))\n> ceval_step__ceval (CIf b c1 c2) st st' (S i ** prf) | False = \n> E_IfFalse (sym bprf) (ceval_step__ceval c2 st st' (i**prf))\n> ceval_step__ceval (CWhile b c) st st' (S i ** prf) with (beval st b) proof bprf\n> ceval_step__ceval (CWhile b c) st st' (S i ** prf) | True with (ceval_step st c i) proof cprf\n> ceval_step__ceval (CWhile b c) st st' (S i ** prf) | True | Just st1 =\n> E_WhileLoop (sym bprf) (ceval_step__ceval c st st1 (i**sym cprf)) \n\n\\todo[inline]{Idris can't see sigma is decreasing, use WellFounded here?}\n\n> (assert_total $ ceval_step__ceval (CWhile b c) st1 st' (i**prf)) \n> ceval_step__ceval (CWhile b c) st st' (S i ** prf) | True | Nothing = absurd prf\n> ceval_step__ceval (CWhile b c) st st (S i ** Refl) | False = E_WhileEnd (sym bprf)\n\n\n==== Exercise: 4 stars (ceval_step__ceval_inf)\n\nWrite an informal proof of \\idr{ceval_step__ceval}, following the usual\ntemplate. (The template for case analysis on an inductively defined value should\nlook the same as for induction, except that there is no induction hypothesis.)\nMake your proof communicate the main ideas to a human reader; do not simply\ntranscribe the steps of the formal proof.\n\n> -- FILL IN HERE\n\n$\\square$\n\n> ceval_step_more : (i1, i2 : Nat) -> (st, st' : State) -> (c : Com) -> LTE i1 i2 -> ceval_step st c i1 = Just st' \n> -> ceval_step st c i2 = Just st'\n> ceval_step_more Z i2 st st' c lte prf = absurd prf\n> ceval_step_more (S i1) Z st st' c lte prf = absurd lte\n> ceval_step_more (S i1) (S i2) st st' CSkip lte prf = prf\n> ceval_step_more (S i1) (S i2) st st' (CAss l a) lte prf = prf\n> ceval_step_more (S i1) (S i2) st st' (CSeq c1 c2) lte prf with (ceval_step st c1 i1) proof cprf\n> ceval_step_more (S i1) (S i2) st st' (CSeq c1 c2) lte prf | Just st1 = \n> rewrite ceval_step_more i1 i2 st st1 c1 (fromLteSucc lte) (sym cprf) in \n> ceval_step_more i1 i2 st1 st' c2 (fromLteSucc lte) prf\n> ceval_step_more (S i1) (S i2) st st' (CSeq c1 c2) lte prf | Nothing = absurd prf\n> ceval_step_more (S i1) (S i2) st st' (CIf b c1 c2) lte prf with (beval st b) proof bprf\n> ceval_step_more (S i1) (S i2) st st' (CIf b c1 c2) lte prf | True = \n> ceval_step_more i1 i2 st st' c1 (fromLteSucc lte) prf\n> ceval_step_more (S i1) (S i2) st st' (CIf b c1 c2) lte prf | False = \n> ceval_step_more i1 i2 st st' c2 (fromLteSucc lte) prf\n> ceval_step_more (S i1) (S i2) st st' (CWhile b c) lte prf with (beval st b) \n> ceval_step_more (S i1) (S i2) st st' (CWhile b c) lte prf | True with (ceval_step st c i1) proof cprf\n> ceval_step_more (S i1) (S i2) st st' (CWhile b c) lte prf | True | Just st1 = \n> rewrite ceval_step_more i1 i2 st st1 c (fromLteSucc lte) (sym cprf) in \n> ceval_step_more i1 i2 st1 st' (CWhile b c) (fromLteSucc lte) prf\n> ceval_step_more (S i1) (S i2) st st' (CWhile b c) lte prf | True | Nothing = absurd prf\n> ceval_step_more (S i1) (S i2) st st' (CWhile b c) lte prf | False = prf\n\n\n==== Exercise: 3 stars, recommended (ceval__ceval_step)\n\nFinish the following proof. You'll need \\idr{ceval_step_more} in a few places,\nas well as some basic facts about \\idr{LTE} and \\idr{S}. \n\n> ceval__ceval_step : (c : Com) -> (st, st' : State) -> (c / st \\\\ st') -> (i ** ceval_step st c i = Just st')\n> ceval__ceval_step c st st' prf = ?ceval__ceval_step_rhs \n\n$\\square$\n\n> ceval_and_ceval_step_coincide : (c : Com) -> (st, st' : State) -> (c / st \\\\ st') <-> (i ** ceval_step st c i = Just st')\n> ceval_and_ceval_step_coincide c st st' = (ceval__ceval_step c st st', ceval_step__ceval c st st')\n\n\n== Determinism of Evaluation Again \n\nUsing the fact that the relational and step-indexed definition of evaluation are\nthe same, we can give a slicker proof that the evaluation _relation_ is\ndeterministic. \n\n> ceval_deterministic' : (c : Com) -> (st, st1, st2 : State) -> (c / st \\\\ st1) -> (c / st \\\\ st2) -> st1 = st2\n> ceval_deterministic' c st st1 st2 prf1 prf2 = \n> let \n> (i1**e1) = ceval__ceval_step c st st1 prf1 \n> (i2**e2) = ceval__ceval_step c st st2 prf2 \n> plus1 = ceval_step_more i1 (i1+i2) st st1 c (lteAddRight i1) e1\n> plus2 = ceval_step_more i2 (i1+i2) st st2 c (rewrite plusCommutative i1 i2 in lteAddRight i2) e2\n> in \n> justInjective $ trans (sym plus1) plus2\n", "meta": {"hexsha": "f24678ec19beb8e83f033f6db2edbceb4ef5e466", "size": 12303, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "src/ImpCEvalFun.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/ImpCEvalFun.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/ImpCEvalFun.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": 42.2783505155, "max_line_length": 165, "alphanum_fraction": 0.6756888564, "num_tokens": 4317, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544210587585, "lm_q2_score": 0.8198933381139645, "lm_q1q2_score": 0.5733140414728132}}
{"text": "module Dijkstra\n\n-- Based on https://www.fstar-lang.org/papers/dm4free/slides.pdf\n\ndata Unit : Type -> Type where\n U : Unit a\n\nSTwp : Type -> Type -> Type\nSTwp s a = s -> (a -> s -> Type) -> Type\n\nST : (s : Type) -> (a : Type) -> STwp s a -> Type\nST s a p = (st : s) -> (k : (a -> s -> Type)) -> Unit (p st k) -> Type\n\nreturnwp : a -> STwp s a\nreturnwp v st k = k v st\n\ngetwp : () -> STwp s s\ngetwp () st k = k st st\n\nsetwp : s -> STwp s ()\nsetwp st _ k = k () st\n\nbindwp : STwp s a -> (a -> STwp s b) -> STwp s b\nbindwp wp f st k = wp st (\\b, st' => f b st' k)\n\nreturn : (v : a) -> ST s a (returnwp v)\nreturn v st k _ = returnwp v st k\n\nget : ST s s (getwp ())\nget st k _ = (getwp ()) st k\n\nset : (st : s) -> ST s () (setwp st)\nset st st' k _ = (setwp st) st' k\n\n(>>=) : {wa : STwp s a} -> {wb : a -> STwp s b} ->\n ST s a wa -> ((x : a) -> ST s b (wb x)) -> ST s b (bindwp wa wb)\n(>>=) m f st k _ = m st (\\v, st' => f v st' k U) U\n\nincr : ST Nat () (\\s, post => post () (S s))\nincr = do x <- get\n set (S x)\n\ntest : incr 0 (\\x, s => 1 = s) U\ntest = Refl\n", "meta": {"hexsha": "840938e5cb588f3d335e48d95b6ee5c855b3c701", "size": 1072, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Dijkstra.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/Dijkstra.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/Dijkstra.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": 23.8222222222, "max_line_length": 72, "alphanum_fraction": 0.4916044776, "num_tokens": 432, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951104066293, "lm_q2_score": 0.6791786861878392, "lm_q1q2_score": 0.573155572366316}}
{"text": "module Main\n\nimport Common.Abbrev\nimport Common.Util\nimport Common.Interfaces\nimport Specifications.Semigroup\nimport Specifications.Monoid\nimport Specifications.Group\nimport Specifications.Order\nimport Specifications.Ring\nimport Specifications.TranslationInvariance\nimport Specifications.OrderedGroup\nimport Specifications.DiscreteOrderedGroup\nimport Specifications.OrderedRing\nimport Symmetry.Opposite\nimport Symmetry.Abelian\nimport Proofs.OrderTheory\nimport Proofs.SemigroupTheory\nimport Proofs.GroupCancelationLemmas\nimport Proofs.GroupTheory\nimport Proofs.GroupCancelMisc\nimport Proofs.TranslationInvarianceTheory\nimport Proofs.DiscreteOrderTheory\nimport Proofs.Interval\nimport Proofs.RingTheory\nimport Instances.Notation\nimport Instances.TrustInteger\nimport Instances.OrderZZ\nimport Instances.ZZ\nimport Applications.Example\n\n%default total\n\ntestAbsoluteValue : Integer -> Integer\ntestAbsoluteValue x = fst $\n absoluteValue (orderedGroup integerDiscreteOrderedGroup) x\n\ntestAbsoluteValueZZ : ZZ -> ZZ\ntestAbsoluteValueZZ x = fst $ absoluteValue zzOrderedGroup x\n\nmain : IO ()\nmain = do printLn $ map testAbsoluteValue [(-5)..5]\n printLn $ map testAbsoluteValueZZ (map fromInteger [(-10)..10])\n", "meta": {"hexsha": "ec79726830d7293be77598497ffbb730ce7d3652", "size": 1207, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Main.idr", "max_stars_repo_name": "jeroennoels/verified-algebra", "max_stars_repo_head_hexsha": "85dfd88fecaf32bd20de72923d2d10de59d8b859", "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/Main.idr", "max_issues_repo_name": "jeroennoels/verified-algebra", "max_issues_repo_head_hexsha": "85dfd88fecaf32bd20de72923d2d10de59d8b859", "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/Main.idr", "max_forks_repo_name": "jeroennoels/verified-algebra", "max_forks_repo_head_hexsha": "85dfd88fecaf32bd20de72923d2d10de59d8b859", "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": 27.4318181818, "max_line_length": 73, "alphanum_fraction": 0.8458989229, "num_tokens": 271, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677583778258, "lm_q2_score": 0.6757645879592642, "lm_q1q2_score": 0.5730265828429324}}
{"text": "\nimport Data.Vect\n\nmyZipWith : (a -> b -> c) -> Vect n a -> Vect n b -> Vect n c\nmyZipWith f [] [] = []\nmyZipWith f (x :: xs) (y :: ys) = f x y :: myZipWith f xs ys\n\n-- ctrl alt a on zipWith\n-- ctrl alt c on first Vect argument\n-- ctrl alt c on second Vect argument\n-- ctrl alt s on first hole\n-- ctrl alt c on second Vect argument in second pattern\n-- ctrl alt s on last hole\n-- DONE\n\nmyAppend : Vect n a -> Vect m a -> Vect (n + m) a\nmyAppend [] ys = ys\nmyAppend (x :: xs) ys = x :: myAppend xs ys\n\n-- type: write or extract a top-level function signature\n-- define: doing stuff on the left\n-- refine: doing stuff on the right\n\nmyTake : (m : Nat) -> Vect (m + n) a -> Vect m a\nmyTake Z xs = []\nmyTake (S k) (x :: xs) = x :: (myTake k xs) -- findet Idris nicht automatisch\n\nmyDrop : (m : Nat) -> Vect (m + n) a -> Vect n a\nmyDrop Z xs = xs\nmyDrop (S k) (x :: xs) = ?hole_2\n\nmyReplicate : (n : Nat) -> a -> Vect n a\nmyReplicate Z x = []\nmyReplicate (S k) x = x :: myReplicate k x -- wird automatisch gefunden\n", "meta": {"hexsha": "9e65a19ae8fdbffe3a414bd26f8b9c1234bb5150", "size": 1009, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "zipWith.idr", "max_stars_repo_name": "fthomas/tdd-talk", "max_stars_repo_head_hexsha": "988657bc2055e2b0d270198a58b1af0531eb8413", "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": "zipWith.idr", "max_issues_repo_name": "fthomas/tdd-talk", "max_issues_repo_head_hexsha": "988657bc2055e2b0d270198a58b1af0531eb8413", "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": "zipWith.idr", "max_forks_repo_name": "fthomas/tdd-talk", "max_forks_repo_head_hexsha": "988657bc2055e2b0d270198a58b1af0531eb8413", "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": 28.8285714286, "max_line_length": 77, "alphanum_fraction": 0.6144697721, "num_tokens": 339, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746911, "lm_q2_score": 0.7371581626286833, "lm_q1q2_score": 0.5729929374750659}}
{"text": "module NonDet\n\n-- Non-determinism, based on http://okmij.org/ftp/tagless-final/nondet-paper.pdf\n\nimport Control.Monad.Identity\n\ninterface NDet (rep : Type -> Type) (val : Type -> Type) | rep where\n nil : rep a\n cons : val a -> rep a -> rep a\n list : List a -> rep a\n decon : rep a -> (() -> rep a) -> (val a -> rep a -> rep a) -> rep a\n foldr : (val a -> rep a -> rep a) -> rep a -> rep a -> rep a\n fail : rep a\n (||) : rep a -> rep a -> rep a\n\ndata Lists : Type -> Type where\n In : List (List a) -> Lists a\n\nNDet Lists Identity where\n nil = In [[]]\n cons (Id y) (In xss) = In $ map (\\xs => y :: xs) xss\n list xs = In [xs]\n decon (In xss) onnil oncons = In $ xss >>= (\\xs => case xs of\n [] => let (In yss) = onnil () in yss\n h :: t => let (In yss) = oncons (Id h) (In [t]) in yss)\n\n foldr f seed (In xss) = In $ xss >>= (\\xs => let (In yss) = foldr (\\x, acc => f (Id x) acc) seed xs in yss)\n\n fail = In []\n (||) (In xs) (In ys) = In (xs ++ ys)\n\ninsert : NDet rep val => val a -> rep a -> rep a\ninsert x l = cons x l || decon l (\\() => fail) (\\h, t => cons h (insert x t))\n\nperm : NDet rep val => List a -> rep a\nperm xs = foldr (\\x, xs => insert x xs) nil (list xs)\n\ntest : Lists Int\ntest = perm [1, 2, 3]\n", "meta": {"hexsha": "51b24abe82bcb0a7cc7dc59f22009a581926cd97", "size": 1327, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/NonDet.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/NonDet.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/NonDet.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.175, "max_line_length": 109, "alphanum_fraction": 0.4981160512, "num_tokens": 450, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8311430478583169, "lm_q2_score": 0.6893056295505783, "lm_q1q2_score": 0.5729115818505636}}
{"text": "data Expr num = Val num\n | Add (Expr num) (Expr num)\n | Sub (Expr num) (Expr num)\n | Mul (Expr num) (Expr num)\n | Div (Expr num) (Expr num)\n | Abs (Expr num)\n\neval : (Abs num, Neg num, Integral num) => Expr num -> num\neval (Val x) = x\neval (Add x y) = eval x + eval y\neval (Sub x y) = eval x - eval y\neval (Mul x y) = eval x * eval y\neval (Div x y) = eval x `div` eval y\neval (Abs x) = abs (eval x)\n\nNum ty => Num (Expr ty) where\n (+) = Add\n (*) = Mul\n fromInteger = Val . fromInteger\n\nNeg ty => Neg (Expr ty) where\n negate x = 0 - x\n (-) = Sub\n\nAbs ty => Abs (Expr ty) where\n abs = Abs\n", "meta": {"hexsha": "36032a1b42cfc05ca16d09533b1ea877d275b106", "size": 670, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/tests/typedd-book/chapter07/Expr.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/typedd-book/chapter07/Expr.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/typedd-book/chapter07/Expr.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": 24.8148148148, "max_line_length": 58, "alphanum_fraction": 0.5104477612, "num_tokens": 219, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8991213799730774, "lm_q2_score": 0.6370307944803832, "lm_q1q2_score": 0.572768007018548}}
{"text": "||| Implements verified regular expressions.\n|||\n||| Implementation is based on https://www.ccs.neu.edu/home/turon/re-deriv.pdf\nmodule RegExp\n\nimport Data.List\nimport Decidable.Equality\n\nimport RegExp.Equivalences\nimport public RegExp.Types\n\n||| Given a regular expression `r` and a string `xs`, determines whether `r` _matches_ `[]` (i.e.\n||| whether empty is in the language of `r`).\nmatchEmpty : (r : RegExp a) -> Dec (Matches r [])\nmatchEmpty Null = No absurd\nmatchEmpty Empty = Yes InEmpty\nmatchEmpty (Lit x) = No absurd\nmatchEmpty (Cat r s) = case (matchEmpty r, matchEmpty s) of\n (Yes pr, Yes ps) => Yes $ InCat Refl pr ps\n (No contra, _) => No $ contra . fst . catNotEmpty\n (_, No contra) => No $ contra . snd . catNotEmpty\nmatchEmpty (Disj r s) = case (matchEmpty r, matchEmpty s) of\n (Yes p, _) => Yes $ InDisjL p\n (_, Yes p) => Yes $ InDisjR p\n (No contraR, No contraS) => No $ absurd . either contraR contraS . disjNotEmpty\nmatchEmpty (Conj r s) = case (matchEmpty r, matchEmpty s) of\n (Yes pr, Yes ps) => Yes $ InConj pr ps\n (No contra, _) => No $ contra . fst . conjNotEmpty\n (_, No contra) => No $ contra . snd . conjNotEmpty\nmatchEmpty (Star r) = Yes InStarZ\n\n||| Computes the derivative of a regular expression `r` with respect to a symbol `x`.\nderive : (DecEq a) => (r : RegExp a) -> (x : a) -> RegExp a\nderive Null _ = Null\nderive Empty _ = Null\nderive (Lit y) x with (decEq y x)\n derive (Lit x) x | (Yes Refl) = Empty\n derive (Lit y) x | (No _) = Null\nderive (Cat r s) x with (matchEmpty r)\n derive (Cat r s) x | (Yes _) = normDisj (normCat (derive r x) s) (derive s x)\n derive (Cat r s) x | (No _) = normCat (derive r x) s\nderive (Disj r s) x = normDisj (derive r x) (derive s x)\nderive (Conj r s) x = normConj (derive r x) (derive s x)\nderive (Star r) x = normCat (derive r x) (Star r)\n\n||| Proof that the derivation-based match algorithm is sound\nderive_isSound : DecEq a =>\n {r : RegExp a} ->\n {x : a} ->\n {xs : List a} ->\n Matches (derive r x) xs ->\n Matches r (x::xs)\nderive_isSound {r=Null} _ impossible\nderive_isSound {r=Empty} _ impossible\nderive_isSound {r=(Lit y)} {x} p with (decEq y x)\n derive_isSound {r=(Lit x)} {x} p | (Yes Refl) = rewrite emptyMatch_implies_emptyList p in InLit\n derive_isSound {r=(Lit y)} {x} p | (No _) = absurd p\nderive_isSound {r=(Cat r s)} {x} p with (matchEmpty r)\n derive_isSound {r=(Cat r s)} {x} p | (Yes pEmpty) with (normDisj_isSound p)\n derive_isSound {r=(Cat r s)} {x} p | (Yes pEmpty) | (InDisjL t) with (normCat_isSound t)\n derive_isSound {r=(Cat r s)} {x} p | (Yes pEmpty) | (InDisjL t) | (InCat pCat u v) = rewrite pCat in InCat Refl (derive_isSound u) v\n derive_isSound {r=(Cat r s)} {x} p | (Yes pEmpty) | (InDisjR t) = InCat Refl pEmpty (derive_isSound t)\n derive_isSound {r=(Cat r s)} {x} p | (No contra) with (normCat_isSound p)\n derive_isSound {r=(Cat r s)} {x} p | (No contra) | (InCat prf t u) = InCat (cong (x::) prf) (derive_isSound t) u\nderive_isSound {r=(Disj r s)} p with (normDisj_isSound p)\n derive_isSound {r=(Disj r s)} p | (InDisjL pr) = InDisjL $ derive_isSound pr\n derive_isSound {r=(Disj r s)} p | (InDisjR ps) = InDisjR $ derive_isSound ps\nderive_isSound {r=(Conj r s)} p with (normConj_isSound p)\n derive_isSound {r=(Conj r s)} p | (InConj pr ps) = InConj (derive_isSound pr) (derive_isSound ps)\nderive_isSound {r=(Star r)} p with (normCat_isSound {s=(Star r)} p)\n derive_isSound {r=(Star r)} p | (InCat prf pr prs) = rewrite prf in InStarS (cong (x::) prf) (derive_isSound pr) prs\n\nmutual\n ||| Proof that the derivation-based match algorithm is complete for `Star`\n deriveStar_isComplete : DecEq a =>\n {r: RegExp a} ->\n {xs' : List a} ->\n (x : a) ->\n (xs : List a) ->\n xs = x :: xs' ->\n Matches (Star r) xs ->\n Matches (normCat (derive r x) (Star r)) xs'\n deriveStar_isComplete _ [] p _ = absurd p\n deriveStar_isComplete {xs'} x _ p (InStarS {xs=[]} {ys} Refl pr ps) =\n deriveStar_isComplete x ys p ps\n deriveStar_isComplete x _ p (InStarS {xs=y::ys} pCat pr ps) =\n let (Refl, Refl) = consInjective p in\n normCat_isComplete $ InCat Refl (derive_isComplete pr) ps\n\n ||| Proof that the derivation-based match algorithm is complete\n derive_isComplete : DecEq a =>\n {r : RegExp a} ->\n {x : a} ->\n {xs : List a} ->\n Matches r (x::xs) ->\n Matches (derive r x) xs\n derive_isComplete {r=Null} p = absurd p\n derive_isComplete {r=Empty} p = absurd p\n derive_isComplete {r=(Lit y)} p with (decEq y x)\n derive_isComplete {r=(Lit x)} p | (Yes Refl) = rewrite litMatchesCons_implies_restEmpty p in InEmpty\n derive_isComplete {r=(Lit y)} p | (No contra) = absurd $ contra $ litMatches_implies_headEqual p\n derive_isComplete {r=(Cat r s)} {x} {xs} p with (matchEmpty r)\n derive_isComplete {r=(Cat r s)} {x} {xs} (InCat {xs=[]} {ys=x::xs} Refl pr ps) | (Yes pEmpty) =\n normDisj_isComplete $ InDisjR $ derive_isComplete ps\n derive_isComplete {r=(Cat r s)} {x} {xs=xs++ys'} (InCat {xs=x::xs} {ys=ys'} Refl pr ps) | (Yes pEmpty) =\n normDisj_isComplete $ InDisjL $ normCat_isComplete $ InCat Refl (derive_isComplete pr) ps\n derive_isComplete {r=(Cat r s)} {x} {xs} (InCat {xs=[]} {ys=x::xs} Refl pr ps) | (No contra) =\n normCat_isComplete $ absurd $ contra pr\n derive_isComplete {r=(Cat r s)} {x} {xs=xs++ys'} (InCat {xs=x::xs} {ys=ys'} Refl pr ps) | (No contra) =\n normCat_isComplete $ InCat Refl (derive_isComplete pr) ps\n derive_isComplete {r=(Disj r s)} (InDisjL p) =\n normDisj_isComplete $ InDisjL $ derive_isComplete p\n derive_isComplete {r=(Disj r s)} (InDisjR p) =\n normDisj_isComplete $ InDisjR $ derive_isComplete p\n derive_isComplete {r=(Conj r s)} (InConj pr ps) =\n normConj_isComplete $ InConj (derive_isComplete pr) (derive_isComplete ps)\n derive_isComplete {r=(Star r)} {x} {xs} p = deriveStar_isComplete x (x::xs) Refl p\n\n||| Given a regular expression `r` and a string `xs`, determines whether `r` _matches_ `u` (i.e.\n||| whether `xs` is in the language of `r`).\nexport\nmatches : DecEq a => (r : RegExp a) -> (xs : List a) -> Dec (Matches r xs)\nmatches r [] = matchEmpty r\nmatches r (x::xs) =\n case matches (derive r x) xs of\n Yes prf => Yes $ derive_isSound prf\n No contra => No $ contra . derive_isComplete\n", "meta": {"hexsha": "91498f641af63034d4aa2b2ade60767ade057fd9", "size": 6939, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/RegExp.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.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.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": 54.2109375, "max_line_length": 138, "alphanum_fraction": 0.5915838017, "num_tokens": 2173, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.815232489352, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.5727253376896546}}
{"text": "module Decidable.Decidable.Extra\n\nimport Data.Rel\nimport Data.Rel.Complement\nimport Data.Fun\nimport Data.Vect\nimport Data.HVect\nimport Data.Fun.Extra\nimport Decidable.Decidable\n\n%default total\n\npublic export\nNotNot : {n : Nat} -> {ts : Vect n Type} -> (r : Rel ts) -> Rel ts\nNotNot r = map @{Nary} (Not . Not) r\n\n[DecidablePartialApplication] {x : t} -> (tts : Decidable (S n) (t :: ts) r) => Decidable n ts (r x) where\n decide = decide @{tts} x\n\npublic export\ndoubleNegationElimination : {n : Nat} -> {0 ts : Vect n Type} -> {r : Rel ts} -> Decidable n ts r =>\n (witness : HVect ts) ->\n uncurry (NotNot {ts} r) witness ->\n uncurry r witness\ndoubleNegationElimination {ts = []} @{dec} [] prfnn =\n case decide @{dec} of\n Yes prf => prf\n No prfn => absurd $ prfnn prfn\ndoubleNegationElimination {ts = t :: ts} @{dec} (w :: witness) prfnn =\n doubleNegationElimination {ts} {r = r w} @{ DecidablePartialApplication @{dec} } witness prfnn\n\ndoubleNegationForall : {n : Nat} -> {0 ts : Vect n Type} -> {r : Rel ts} -> Decidable n ts r =>\n All ts (NotNot {ts} r) -> All ts r\ndoubleNegationForall @{dec} forall_prf =\n let prfnn : (witness : HVect ts) -> uncurry (NotNot {ts} r) witness\n prfnn = uncurryAll forall_prf\n prf : (witness : HVect ts) -> uncurry r witness\n prf witness = doubleNegationElimination @{dec} witness (prfnn witness)\n in curryAll prf\n\npublic export\ndoubleNegationExists : {n : Nat} -> {0 ts : Vect n Type} -> {r : Rel ts} -> Decidable n ts r =>\n Ex ts (NotNot {ts} r) ->\n Ex ts r\ndoubleNegationExists @{dec} nnxs =\n let witness : HVect ts\n witness = extractWitness nnxs\n witnessingnn : uncurry (NotNot {ts} r) witness\n witnessingnn = extractWitnessCorrect nnxs\n witnessing : uncurry r witness\n witnessing = doubleNegationElimination @{dec} witness witnessingnn\n in introduceWitness witness witnessing\n\n\n\n\ndecideTransform :\n {n : Nat}\n -> {ts : Vect n Type}\n -> {r : Rel ts}\n -> {t : Type -> Type}\n -> (tDec : {a : Type} -> Dec a -> Dec (t a))\n -> (posDec : IsDecidable n ts r)\n -> IsDecidable n ts (chain {ts} t r)\ndecideTransform tDec posDec =\n curryAll $ \\xs =>\n replace {p = id} (chainUncurry (chain t r) Dec xs) $\n replace {p = Dec} (chainUncurry r t xs) $\n tDec $ replace {p = id} (sym $ chainUncurry r Dec xs) $\n uncurryAll posDec xs\n\n\n||| Convert a decision about a decidable property into one about its negation.\npublic export\nnegateDec : (dec : Dec a) -> Dec (Not a)\nnegateDec (Yes pf) = No ($ pf)\nnegateDec (No npf) = Yes npf\n\n||| We can turn (Not (Exists Not)) into Forall for decidable types\npublic export\nnotExistsNotForall :\n {0 p : a -> Type}\n -> ((x : a) -> Dec (p x))\n -> Dec (x : a ** Not (p x))\n -> Dec ((x : a) -> p x)\nnotExistsNotForall dec decEx =\n case decEx of\n Yes (x ** nx) => No $ \\f => nx $ f x\n No notNot => Yes $ \\x => case (dec x) of\n Yes px => px\n No nx => void $ notNot $ (x ** nx)\n\n\n||| If a relation is decidable, then so is its complement\npublic export\n[DecidableComplement] {n : Nat} -> {ts : Vect n Type} -> {r : Rel ts} -> (posDec : Decidable n ts r) =>\n Decidable n ts (complement {ts} r) where\n decide = decideTransform negateDec (decide @{posDec})\n", "meta": {"hexsha": "aa0d124bcd72de77d569ee4867a071a3633c8634", "size": 3268, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/contrib/Decidable/Decidable/Extra.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/Decidable/Decidable/Extra.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/Decidable/Decidable/Extra.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": 33.0101010101, "max_line_length": 106, "alphanum_fraction": 0.6227050184, "num_tokens": 1067, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772253241803, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.5724285735279663}}
{"text": "module Naperian\n\n-- Naperian Functors, based on https://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/aplicative.pdf\n\nimport Data.Vect\nimport Data.Fin\n\n\ninterface Functor f => Naperian (f : Type -> Type) where\n Log : {f : Type} -> Type\n lookup' : f a -> (Log -> a)\n positions : f Log\n tabulate : (Log -> a) -> f a\n\n positions = tabulate id\n\nNaperian (Vect n) where\n Log {n} = Fin n\n\n lookup' [] FZ impossible\n lookup' [] (FS _) impossible\n lookup' (x :: xs) FZ = x\n lookup' (x :: xs) (FS y) = lookup' xs y\n\n tabulate h = map h positions\n where\n positions = positions' (replicate _ ())\n where\n positions' : Vect n () -> Vect n (Fin n)\n positions' [] = []\n positions' (() :: xs) = FZ :: map FS (positions' xs)\n\n\ntranspose' : (Naperian f, Naperian g) => f (g a) -> g (f a)\ntranspose' source = (map tabulate . tabulate . flip . lookup' . map lookup') source\n\nexample : Vect 2 (Vect 3 Integer)\nexample = [[1, 2, 3], [4, 5, 6]]\n\ntransposedExample : Vect 3 (Vect 2 Integer)\ntransposedExample = transpose' example\n", "meta": {"hexsha": "b37437b637c7fc2250d33824953e67e81d1fe877", "size": 1064, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Naperian.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/Naperian.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/Naperian.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.3333333333, "max_line_length": 104, "alphanum_fraction": 0.6071428571, "num_tokens": 339, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110454379297, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.5713261192121155}}
{"text": "||| Ugly code for calculating and rendering a dragon curve\n||| in SVG. TODO: Cleanup, document.\nmodule Examples.Fractals.Dragon\n\nimport Data.DPair\nimport Data.List\nimport Data.List.TR\nimport Data.String\n\nrecord Point where\n constructor P\n x,y : Int32\n\nNum Point where\n fromInteger n = P (fromInteger n) 0\n P x1 y1 + P x2 y2 = P (x1 + x2) (y1 + y2)\n P x1 y1 * P x2 y2 = P (x1 * x2 - y1 * y2) (x1 * y2 + x2 * y1)\n\nNeg Point where\n negate (P x y) = P (-x) (-y)\n P x1 y1 - P x2 y2 = P (x1 - x2) (y1 - y2)\n\nrotate90 : Point -> Point\nrotate90 (P x y) = P y (-x)\n\nrotateAround90 : (origin : Point) -> Point -> Point\nrotateAround90 o p = rotate90 (p - o) + o\n\nDragon : Type\nDragon = Subset (List Point) NonEmpty\n\n0 lemma : (as : List a)\n -> (v : a)\n -> (as2 : List a)\n -> NonEmpty (as ++ v :: as2)\nlemma [] v as2 = IsNonEmpty\nlemma (h :: t) v as2 = IsNonEmpty\n\nfirstDragon : Dragon\nfirstDragon = Element [0,800] IsNonEmpty\n\nnextDragon : Dragon -> Dragon\nnextDragon (Element (h :: t) prf) =\n let new = mapTR (rotateAround90 h) (reverse t)\n in Element (new ++ h :: t) (lemma new h t)\n\ndragonSVG : (n : Nat) -> Dragon -> String\ndragonSVG n (Element ps _) =\n let fact = pow 2 (cast (n + 2) / 2.0)\n scale = 1.0 / fact\n\n attr = fastConcat $ mapTR (\\(P x y) => #\"\\#{show x}, \\#{show y} \"#) ps\n header =\n the String #\"\"\"\n \n \"\"\"#\n\nexport\nmkDragons : (n : Nat) -> Subset (List String) NonEmpty\nmkDragons n =\n let fd = firstDragon\n in Element (dragonSVG 0 fd :: go fd n 1) IsNonEmpty\n where go : Dragon -> (rem : Nat) -> (iter : Nat) -> List String\n go _ 0 _ = Nil\n go dr (S k) n =\n let nextDr = nextDragon dr\n in dragonSVG n nextDr :: go nextDr k (n+1)\n", "meta": {"hexsha": "6dd2b4366832e28005aed8ff5a76633a4fb94fd1", "size": 2250, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Examples/Fractals/Dragon.idr", "max_stars_repo_name": "mattpolzin/idris2-rhone-js", "max_stars_repo_head_hexsha": "8ddde9db0dbd20e4ac8fbf22da990fde96399c25", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 11, "max_stars_repo_stars_event_min_datetime": "2021-09-30T15:53:56.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-21T04:39:54.000Z", "max_issues_repo_path": "src/Examples/Fractals/Dragon.idr", "max_issues_repo_name": "mattpolzin/idris2-rhone-js", "max_issues_repo_head_hexsha": "8ddde9db0dbd20e4ac8fbf22da990fde96399c25", "max_issues_repo_licenses": ["BSD-3-Clause"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2021-11-04T04:53:54.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-09T03:42:48.000Z", "max_forks_repo_path": "src/Examples/Fractals/Dragon.idr", "max_forks_repo_name": "mattpolzin/idris2-rhone-js", "max_forks_repo_head_hexsha": "8ddde9db0dbd20e4ac8fbf22da990fde96399c25", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2022-01-27T01:22:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-27T01:22:26.000Z", "avg_line_length": 27.7777777778, "max_line_length": 76, "alphanum_fraction": 0.5333333333, "num_tokens": 716, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619091240701, "lm_q2_score": 0.6926419831347361, "lm_q1q2_score": 0.5710569317547466}}
{"text": "module SMTLib\n\nimport Data.Vect\n\n%access public export\n\ndata NumTyp = IntT | RealT\n\ndata TypeT : Type where\n BoolT : TypeT\n NumT : NumTyp -> TypeT\n BitVecT : Nat -> TypeT\n\nShow TypeT where\n show BoolT = \"Bool\"\n show (NumT IntT) = \"Int\"\n show (NumT RealT) = \"Real\"\n show (BitVecT n) = \"BitVec \" ++ show n\n\n\ndata Expr : TypeT -> Type where\n VarExpr : String -> (t : TypeT) -> Expr t\n BoolExpr : Bool -> Expr BoolT\n BvExpr : Int -> (n : Nat) -> Expr (BitVecT n)\n BvAddExpr : Expr (BitVecT n) -> Expr (BitVecT n) -> Expr (BitVecT n)\n BvMulExpr : Expr (BitVecT n) -> Expr (BitVecT n) -> Expr (BitVecT n)\n BvAndExpr : Expr (BitVecT n) -> Expr (BitVecT n) -> Expr (BitVecT n)\n BvOrExpr : Expr (BitVecT n) -> Expr (BitVecT n) -> Expr (BitVecT n)\n BvNotExpr : Expr (BitVecT n) -> Expr (BitVecT n)\n IntExpr : Int -> Expr (NumT IntT)\n RealExpr : Double -> Expr (NumT RealT)\n AddExpr : Expr (NumT a) -> Expr (NumT a) -> Expr (NumT a)\n MulExpr : Expr (NumT a) -> Expr (NumT a) -> Expr (NumT a)\n EqualExpr : Expr a -> Expr a -> Expr BoolT\n DistinctExpr : Vect n (Expr a) -> Expr BoolT\n LessOrEqualExpr : Expr (NumT a) -> Expr (NumT a) -> Expr BoolT\n AndExpr : Vect n (Expr BoolT) -> Expr BoolT\n OrExpr : Vect n (Expr BoolT) -> Expr BoolT\n NotExpr : Expr BoolT -> Expr BoolT\n IteExpr : Expr BoolT -> Expr a -> Expr a -> Expr a\n\n\n\nbool : Bool -> Expr BoolT\nbool x = BoolExpr x\n\nbv : Int -> (n : Nat) -> Expr (BitVecT n)\nbv x n = BvExpr x n\n\nint : Int -> Expr (NumT IntT)\nint x = IntExpr x\n\nreal : Double -> Expr (NumT RealT)\nreal x = RealExpr x\n\nbvadd : Expr (BitVecT n) -> Expr (BitVecT n) -> Expr (BitVecT n)\nbvadd l r = BvAddExpr l r\n\nbvmul : Expr (BitVecT n) -> Expr (BitVecT n) -> Expr (BitVecT n)\nbvmul l r = BvMulExpr l r\n\nbvand : Expr (BitVecT n) -> Expr (BitVecT n) -> Expr (BitVecT n)\nbvand l r = BvAndExpr l r\n\nbvor : Expr (BitVecT n) -> Expr (BitVecT n) -> Expr (BitVecT n)\nbvor l r = BvOrExpr l r\n\nbvnot : Expr (BitVecT n) -> Expr (BitVecT n)\nbvnot x = BvNotExpr x\n\n(+) : Expr (NumT a) -> Expr (NumT a) -> Expr (NumT a)\n(+) l r = AddExpr l r\n\n(*) : Expr (NumT a) -> Expr (NumT a) -> Expr (NumT a)\n(*) l r = MulExpr l r\n\n(==) : Expr a -> Expr a -> Expr BoolT\n(==) l r = EqualExpr l r\n\ndistinct : Vect n (Expr a) -> Expr BoolT\ndistinct xs = DistinctExpr xs\n\n(<=) : Expr (NumT a) -> Expr (NumT a) -> Expr BoolT\n(<=) l r = LessOrEqualExpr l r\n\n(&&) : Expr BoolT -> Expr BoolT -> Expr BoolT\n(&&) l r = AndExpr [l, r]\n\n(||) : Expr BoolT -> Expr BoolT -> Expr BoolT\n(||) l r = OrExpr [l, r]\n\nand : Vect n (Expr BoolT) -> Expr BoolT\nand xs = AndExpr xs\n\nor : Vect n (Expr BoolT) -> Expr BoolT\nor xs = OrExpr xs\n\nnot : Expr BoolT -> Expr BoolT\nnot x = NotExpr x\n\nite : Expr BoolT -> Expr a -> Expr a -> Expr a\nite p l r = IteExpr p l r\n\ndata Cmd : Type -> Type where\n DeclareVarCmd : String -> (t : TypeT) -> Cmd (Expr t)\n DeclareVarsCmd : Traversable f => f String -> (t : TypeT) -> Cmd (f (Expr t))\n AssertCmd : Expr BoolT -> Cmd ()\n CheckSatCmd : Cmd ()\n GetModelCmd : Cmd ()\n\ndeclareVar : String -> (t : TypeT) -> Cmd (Expr t)\ndeclareVar v t = DeclareVarCmd v t\n\ndeclareVars : Traversable f => f String -> (t : TypeT) -> Cmd (f (Expr t))\ndeclareVars vs t = DeclareVarsCmd vs t\n\nassert : Expr BoolT -> Cmd ()\nassert e = AssertCmd e\n\ncheckSat : Cmd ()\ncheckSat = CheckSatCmd\n\ngetModel : Cmd ()\ngetModel = GetModelCmd\n\ndata Smt : Type -> Type where\n Pure : a -> Smt a\n Bind : Cmd a -> (a -> Smt b) -> Smt b\n\npure : a -> Smt a\npure x = Pure x\n\n(>>=) : Cmd a -> (a -> Smt b) -> Smt b\n(>>=) cmd f = Bind cmd f\n\nend : Smt ()\nend = Pure ()\n\ncompileExpr : Expr t -> String\ncompileExpr (VarExpr x t) = x\ncompileExpr (BoolExpr x) = if x then \"true\" else \"false\"\ncompileExpr (BvExpr x n) = \"(_ bv\" ++ show x ++ \" \" ++ show n ++ \")\"\ncompileExpr (IntExpr x) = show x\ncompileExpr (RealExpr x) = show x\ncompileExpr (BvAddExpr l r) = \"(bvadd \" ++ compileExpr l ++ \" \" ++ compileExpr r ++ \")\"\ncompileExpr (BvMulExpr l r) = \"(bvmul \" ++ compileExpr l ++ \" \" ++ compileExpr r ++ \")\"\ncompileExpr (BvAndExpr l r) = \"(bvand \" ++ compileExpr l ++ \" \" ++ compileExpr r ++ \")\"\ncompileExpr (BvOrExpr l r) = \"(bvor \" ++ compileExpr l ++ \" \" ++ compileExpr r ++ \")\"\ncompileExpr (BvNotExpr x) = \"(bnot \" ++ compileExpr x ++ \")\"\ncompileExpr (AddExpr l r) = \"(+ \" ++ compileExpr l ++ \" \" ++ compileExpr r ++ \")\"\ncompileExpr (MulExpr l r) = \"(* \" ++ compileExpr l ++ \" \" ++ compileExpr r ++ \")\"\ncompileExpr (EqualExpr l r) = \"(= \" ++ compileExpr l ++ \" \" ++ compileExpr r ++ \")\"\ncompileExpr (DistinctExpr xs) = \"(distinct \" ++ (unlines . toList . map compileExpr) xs ++ \")\"\ncompileExpr (LessOrEqualExpr l r) = \"(<= \" ++ compileExpr l ++ \" \" ++ compileExpr r ++ \")\"\ncompileExpr (AndExpr xs) = \"(and \" ++ (unlines . toList . map compileExpr) xs ++ \")\"\ncompileExpr (OrExpr xs) = \"(or \" ++ (unlines . toList . map compileExpr) xs ++ \")\"\ncompileExpr (NotExpr x) = \"(not \" ++ compileExpr x ++ \")\"\ncompileExpr (IteExpr p l r) = \"(if \" ++ compileExpr p ++ \" \" ++ compileExpr l ++ \" \" ++ compileExpr r ++ \")\"\n\ncompileCmd : Cmd a -> (a, String)\ncompileCmd (DeclareVarCmd x t) = (VarExpr x t, \"(declare-const \" ++ x ++ \" \" ++ show t ++ \")\")\ncompileCmd (DeclareVarsCmd xs t) = (map (\\x => VarExpr x t) xs,\n (unlines . toList . map (\\x => \"(declare-const \" ++ x ++ \" \" ++ show t ++ \")\")) xs)\ncompileCmd (AssertCmd e) = ((), \"(assert \" ++ compileExpr e ++ \")\")\ncompileCmd CheckSatCmd = ((), \"(check-sat)\")\ncompileCmd GetModelCmd = ((), \"(get-model)\")\n\ncompile : Smt () -> String\ncompile (Pure ()) = \"\"\ncompile (Bind cmd f) = let (a, s) = compileCmd cmd in\n let s' = compile $ f a in\n unlines [s, s']\n\nexample0 : Expr BoolT\nexample0 = (bool True) && (bool True)\n\nexample1 : Expr BoolT\nexample1 = (bv 1 8) == (bv 1 8)\n\nexample2 : Cmd ()\nexample2 = checkSat\n\nexample3 : Smt ()\nexample3 = do x <- declareVar \"x\" BoolT\n y <- declareVar \"y\" BoolT\n assert $ x && y\n checkSat\n getModel\n end\n\nexample4 : Smt ()\nexample4 = do [x, y] <- declareVars {f = Vect 2} [\"x\", \"y\"] BoolT\n assert $ not (x && y) == (not x || not y)\n checkSat\n getModel\n end\n\nprint : Smt () -> IO ()\nprint smt = putStrLn $ compile smt\n", "meta": {"hexsha": "fcad759be1267d7b1cd7c0dafa7b03279041de7a", "size": 6270, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/SMTLib.idr", "max_stars_repo_name": "vikfret/idris-snippets", "max_stars_repo_head_hexsha": "ae006f79275bf5df2d9152f0f12f8e961492972c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-09-20T00:29:09.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:29:09.000Z", "max_issues_repo_path": "src/SMTLib.idr", "max_issues_repo_name": "vikfret/idris-snippets", "max_issues_repo_head_hexsha": "ae006f79275bf5df2d9152f0f12f8e961492972c", "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/SMTLib.idr", "max_forks_repo_name": "vikfret/idris-snippets", "max_forks_repo_head_hexsha": "ae006f79275bf5df2d9152f0f12f8e961492972c", "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.35, "max_line_length": 119, "alphanum_fraction": 0.5816586922, "num_tokens": 2130, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833841649233, "lm_q2_score": 0.7371581568543043, "lm_q1q2_score": 0.5709904598009844}}
{"text": "module Sub04LTE216t153\n\nimport ProofColDivSeqBase\nimport ProofColDivSeqPostulate\n\n%default total\n\n\n-- 6(36t+25)+3 --AE[6,-2,-4]--> 6(4t+1)+3\nexport\nlte216t153 : (m : Nat) -> LTE (S (S ((m+m)+(m+m))))\n (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))))))))\nlte216t153 Z = (lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . LTESucc . LTESucc) LTEZero\nlte216t153 (S m) =\n let lemma = lte216t153 m in\n\n rewrite (sym (plusSuccRightSucc m m)) in\n\n rewrite (sym (plusSuccRightSucc (plus m m) (S (plus m m)))) in\n rewrite (sym (plusSuccRightSucc (plus m m) (plus m m))) in\n\n rewrite (sym (plusSuccRightSucc (plus m m) m)) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus m m) m) (S (S (S (plus (plus m m) m)))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus m m) m) (S (S (plus (plus m m) m))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus m m) m) (S (plus (plus m m) m)))) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (S (S (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (S (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m))))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m)))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))\n (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m)))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))\n (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))\n (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m)))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))\n (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))\n (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m)))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))\n (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))\n (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m)))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))\n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus m m) m) (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m) (S (plus (plus m m) m)))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m)))))))))))) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m))))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m)))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))))))\n (S (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m))))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))))))\n (S (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m)))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))))))\n (S (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m))))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))))))\n (S (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m)))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))))))\n (S (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m))))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))))))\n (S (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m)))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))))))\n (S (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m))))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))))))\n (S (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m)))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))))))\n (S (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))))))))))\n (S (S (S (plus (plus (plus (plus m m) m)\n (S (plus (plus m m) m)))\n (S (S (S (plus (plus (plus m m) m)\n (S (plus (plus m m)\n m)))))))))))) in\n\n (lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . LTESucc . LTESucc . LTESucc . LTESucc) lemma\n\n\n\n", "meta": {"hexsha": "7c7a28039c4e4e093280413d3f3b075832cdce67", "size": 23708, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "program3/Sub04LTE216t153.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/Sub04LTE216t153.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/Sub04LTE216t153.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": 82.606271777, "max_line_length": 529, "alphanum_fraction": 0.270921208, "num_tokens": 5490, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9059898153067649, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.5705693802472148}}
{"text": "module Desc\ndata Desc : (0 tI : Type) -> (0 tO : tI -> Type) -> Type where\n End : (i : tI) -> tO i -> Desc tI tO\n Rec : (i : tI) -> (b : tO i -> Desc tI tO) -> Desc tI tO\n Ref : (i : tA -> tI) \n -> ((o : (a : tA) -> tO (i a)) -> Desc tI tO) \n -> Desc tI tO\n Arg : (tA : Type) -> (tA -> Desc tI tO) -> Desc tI tO\n \nel : (d : Desc tI tO) \n -> (tX : tI -> Type )\n -> (tY : {i : tI} -> tX i -> tO i)\n -> tI -> Type \nel (End j o) tX tY i = i = j\nel (Rec j b) tX tY i = (x : (tX j) ** el (b (tY x)) tX tY i )\nel (Ref j b) tX tY i = ( f : ((a : _) -> tX (j a)) ** el (b (\\a => tY (f a))) tX tY i)\nel (Arg tA b) tX tY i = (a : _ ** el (b a) tX tY i)\n\nmutual\n data Fix : (0 d : Desc tI tO) -> (i : tI) -> Type where\n init : el d (Fix d) (foldO {tI = tI} d) i -> Fix d i\n \n foldO : {0 tO : tI -> Type} -> (d : Desc tI tO) -> (1 _ : Fix d i) -> tO i \n foldsO : {0 tO : tI -> Type} -> (1 d : Desc tI tO) \n -> (e : Desc tI tO) -> el d (Fix e) (foldO e) i\n -> tO i\n \n foldO d (init xs) = foldsO d d xs\n foldsO (End j o) e Refl = o\n foldsO (Rec j b) e (x ** xs) = foldsO (b (foldO e x)) e xs\n foldsO (Ref j b) e (f ** xs) = foldsO (b (\\a => foldO e (f a))) e xs\n foldsO (Arg tA b) e (a ** xs) = foldsO (b a) e xs\n\n\ntHyps : (1 d : Desc tI tO) -> (tX : tI -> Type) -> (tY : {i : tI} -> tX i -> tO i)\n -> (p : {0 i : tI} -> tX i -> Type) -> (i : tI) -> (xs : el d tX tY i) -> Type\ntHyps (End j o) tX tY p i x = ()\ntHyps (Rec j d) tX tY p i (x ** xs) = (p x , tHyps (d (tY x)) tX tY p i xs)\ntHyps (Ref j d) tX tY p i (f ** xs) = ((a : _) -> p (f a) , tHyps (d (\\a => tY (f a))) tX tY p i xs)\ntHyps (Arg tA b) tX tY p i (a ** xs) = tHyps (b a) tX tY p i xs\n\n\nmutual\n ind : (d : Desc tI tO) \n -> (0 p : {i : _} -> Fix d i -> Type )\n -> (alpha : {i : _} \n -> (xs : el d (Fix d) (foldO d) i) \n -> (ihs : tHyps d (Fix d) (foldO d) p i xs)\n -> (p (init {i = i} xs)))\n -> {i : tI} -> (x : Fix d i) -> (p x)\n \n hyps : (d : Desc tI tO) -> (e : Desc tI tO) \n -> (0 p : {i : _} -> Fix e i -> Type)\n -> (alpha : {i : _} \n -> (xs : el e (Fix e) (foldO e) i)\n -> (ihs : tHyps e (Fix e) (foldO e) p i xs)\n -> p (init {i = i} xs))\n -> {i : tI} -> (xs : el d (Fix e) (foldO e) i)\n -> tHyps d (Fix e) (foldO e) p i xs\n \n ind d p alpha (init xs) = alpha xs (hyps d d p alpha xs)\n \n hyps (End i o) e p alpha x = ()\n hyps (Rec i b) e p alpha (x ** xs) = (ind e p alpha x , hyps (b (foldO e x)) e p alpha xs)\n hyps (Ref i b) e p alpha (f ** xs) = ((\\a => ind e p alpha (f a)), hyps (b (\\a => foldO e (f a))) e p alpha xs )\n hyps (Arg tA b) e p alpha (a ** xs) = hyps (b a) e p alpha xs\n", "meta": {"hexsha": "2d6c75e122c064e15fd2b4a61d66570af3d8a1cc", "size": 2689, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Desc.idr", "max_stars_repo_name": "JoeyEremondi/idris2-DescIR", "max_stars_repo_head_hexsha": "094c9829a8c128c23b9a19d7473dd5312bf55364", "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": "Desc.idr", "max_issues_repo_name": "JoeyEremondi/idris2-DescIR", "max_issues_repo_head_hexsha": "094c9829a8c128c23b9a19d7473dd5312bf55364", "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": "Desc.idr", "max_forks_repo_name": "JoeyEremondi/idris2-DescIR", "max_forks_repo_head_hexsha": "094c9829a8c128c23b9a19d7473dd5312bf55364", "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": 40.1343283582, "max_line_length": 114, "alphanum_fraction": 0.4362216437, "num_tokens": 1250, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615381987656672, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.5702718364358298}}
{"text": "module Decidable.Equality.Indexed\n\n%default total\n%access public export\n\ninterface DecEq iTy\n => DecEqIdx (iTy : Type)\n (eTy : iTy -> Type) | eTy\n where\n decEq : {i,j : iTy}\n -> (x : eTy i)\n -> (y : eTy j)\n -> (prf : i = j)\n -> Dec (x = y)\n", "meta": {"hexsha": "2d2a877296700f7aaaec0b216a1cd922f28abce5", "size": 305, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Decidable/Equality/Indexed.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": "Decidable/Equality/Indexed.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": "Decidable/Equality/Indexed.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": 20.3333333333, "max_line_length": 44, "alphanum_fraction": 0.4590163934, "num_tokens": 98, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7799928900257126, "lm_q2_score": 0.7310585844894971, "lm_q1q2_score": 0.5702204980940695}}
{"text": "> module InfiniteHorizonSequentialDecisionProblems.Lala\n\n> import Data.Vect\n> import Syntax.PreorderReasoning\n\n> import Finite.Predicates\n> import Finite.Operations\n> import Finite.Properties\n> import Vect.Operations\n> import Vect.Properties\n> import Pair.Properties\n\n> %default total\n> %access public export\n> %auto_implicits off\n\n\n* ---------\n* Sequences\n* ---------\n\n> Seq : Type -> Type\n> Seq A = Nat -> A\n\n> head : {A : Type} -> Seq A -> A\n> head f = f Z\n\n> tail : {A : Type} -> Seq A -> Seq A\n> tail f = f . S\n\n> cons : {A : Type} -> A -> Seq A -> Seq A\n> cons a f Z = a\n> cons a f (S n) = f n \n\n> headLemma : {A : Type} -> (a : A) -> (f : Seq A) -> head (cons a f) = a\n> headLemma a f = Refl\n\n> tailLemma : {A : Type} -> (a : A) -> (f : Seq A) -> tail (cons a f) = f\n> tailLemma a d = Refl\n\n> consLemma : {A : Type} -> (f : Seq A) -> (n : Nat) -> cons (head f) (tail f) n = f n\n> consLemma f Z = Refl\n> consLemma f (S n) = Refl\n\n\n* ---------\n* Fix point\n* ---------\n\n> FixPoint : {X : Type} -> X -> (X -> X) -> Type\n> FixPoint x f = x = f x\n\n\n* ----------------------------\n* Sequential decision problems\n* ----------------------------\n\n> State : Type\n> Ctrl : (x : State) -> Type\n> next : (x : State) -> (y : Ctrl x) -> State\n> Val : Type\n> reward : (x : State) -> (y : Ctrl x) -> State -> Val\n> (<+>) : Val -> Val -> Val\n> LTE : Val -> Val -> Type\n\n\n* --------------------------------------\n* Policies and infinite policy sequences\n* --------------------------------------\n\n> Policy : Type\n> Policy = (x : State) -> Ctrl x\n\n> PolicySeq : Type\n> -- PolicySeq = Nat -> Policy\n> PolicySeq = Seq Policy\n\n\n* ---------------------------------------\n* The value of infinite policiy sequences\n* ---------------------------------------\n\nThe value of making infinite many decision steps with a policy sequence\nby starting from a given state is given by a \"value\" function\n\n> val : PolicySeq -> State -> Val\n\nthat fulfils the specification\n\n> valSpec : Type\n> valSpec = (ps : PolicySeq) -> (x : State) -> \n> val ps x = reward x (head ps x) (next x (head ps x)) \n> <+> \n> val (tail ps) (next x (head ps x))\n\nA naive attempt at implementing |val| directly \"from its specification\"\n\n< val ps x = reward x (head ps x) (next x (head ps x)) <+> val (tail ps) (next x (head ps x))\n\nyiels a possibly non total function. In contrast to SDPs with a finite\nnumber of decision steps, we cannot rely on an induction principle for\ndecision problems over an infinite number of steps. Obviously, there are\ncases in which |val| can be implemented. For instance, if all states\nhave the same successor. An important case is when |State| is finite. We\ndiscuss this case below.\n\n\n* ------------------------------\n* Optimality of policy sequences\n* ------------------------------\n\n> Opt : PolicySeq -> Type\n> Opt ps = (ps' : PolicySeq) -> (x : State) -> val ps' x `LTE` val ps x\n\n\n* ------------------------\n* Optimal policy sequences\n* ------------------------\n\nLet |LTE| be a preorder\n\n> reflexiveLTE : (a : Val) -> a `LTE` a\n> transitiveLTE : {a, b, c : Val} -> a `LTE` b -> b `LTE` c -> a `LTE` c\n\nand let |<+>| be monotonous w.r.t. |LTE|\n\n> monotonePlusLTE : {a, b, c, d : Val} -> a `LTE` b -> c `LTE` d -> (a <+> c) `LTE` (b <+> d)\n\nWe can compute the value of making a first decision step with a given\ncontrol and then infinitely many further steps with a given policy\nsequence in terms of the (yet to be implemented) |val| function:\n\n> cval : (ps : PolicySeq) -> (x : State) -> Ctrl x -> Val\n> cval ps x y = reward x y (next x y) <+> val ps (next x y)\n\nAssume that, for an arbitrary policy sequence |ps| and for an arbitrary\nstate |x|, we can pick up a control that maximises |cval ps x|:\n\n> cvalmax : (ps : PolicySeq) -> (x : State) -> Val\n> cvalargmax : (ps : PolicySeq) -> (x : State) -> Ctrl x\n\n> cvalargmaxSpec : (ps : PolicySeq) -> (x : State) -> cvalmax ps x = cval ps x (cvalargmax ps x)\n> cvalmaxSpec : (ps : PolicySeq) -> (x : State) -> (y : Ctrl x) -> cval ps x y `LTE` cvalmax ps x\n\nThis is certainly the case if |Ctrl x| is non empty and finite for any\n|x| but there are more interesting cases in which we can compute \"best\"\ncontrols. In these cases, we can compute policies that are optimal\nextensions of arbitrary policy sequences:\n\n> OptExt : Policy -> PolicySeq -> Type\n> OptExt p ps = (p' : Policy) -> (x : State) -> val (cons p' ps) x `LTE` val (cons p ps) x\n\n> optExt : (ps : PolicySeq) -> Policy\n> optExt = cvalargmax\n\n> optExtLemma : (ps : PolicySeq) -> (optExt ps) `OptExt` ps\n> optExtLemma ps p' x = s5 where\n> p : Policy\n> p = optExt ps\n> s1 : cval ps x (p' x) `LTE` cvalmax ps x\n> s1 = cvalmaxSpec ps x (p' x)\n> s2 : reward x (p' x) (next x (p' x)) <+> val ps (next x (p' x)) `LTE` cvalmax ps x\n> s2 = s1\n> s3 : reward x (p' x) (next x (p' x)) <+> val ps (next x (p' x)) `LTE` cval ps x (p x)\n> s3 = replace {P = \\ X => reward x (p' x) (next x (p' x)) <+> val ps (next x (p' x)) `LTE` X} (cvalargmaxSpec ps x) s2\n> s4 : reward x (p' x) (next x (p' x)) <+> val ps (next x (p' x)) `LTE` reward x (p x) (next x (p x)) <+> val ps (next x (p x))\n> s5 : val (cons p' ps) x `LTE` val (cons p ps) x\n> s5 = ?s5prf -- via valSpec, headLemma, tailLemma\n\nThis is interesting because of\n\n> Bellman : (ps : PolicySeq) -> Opt ps ->\n> (p : Policy) -> p `OptExt` ps ->\n> Opt (cons p ps)\n> Bellman ps ops p oep = opps where\n> opps : Opt (cons p ps)\n> opps ps' x = s7 where\n> p' : Policy\n> p' = head ps'\n> ps'' : PolicySeq\n> ps'' = tail ps'\n> s4 : val (cons p' ps'') x `LTE` val (cons p' ps) x\n> s4 = ?s4prf\n> s5 : val (cons p' ps) x `LTE` val (cons p ps) x\n> s5 = ?s5prf\n> s6 : val (cons p' ps'') x `LTE` val (cons p ps) x\n> s6 = transitiveLTE s4 s5\n> s7 : val ps' x `LTE` val (cons p ps) x\n> s7 = ?s7prf -- via valSpec, consLemma, ... \n\nI am not sure that this is going to help us but it looks remarkably\nsimilar to the finite horizon case. Perhaps a first step towards\nsomething like\n\n> piter : (Policy, PolicySeq) -> (Policy, PolicySeq)\n> piter (p, ps) = (optExt ps, cons (optExt ps) ps)\n\n> piterLemma : (p : Policy) -> (ps : PolicySeq) -> \n> (p, ps) `FixPoint` piter ->\n> (n : Nat) -> ps n = p\n> piterLemma p ps fp Z = ( ps Z )\n> ={ Refl }=\n> ( head ps )\n> ={ cong (pairEqElimSnd fp) }= \n> ( head (cons (optExt ps) ps) )\n> ={ headLemma (optExt ps) ps }= \n> ( optExt ps )\n> ={ sym (pairEqElimFst fp) }=\n> ( p )\n> QED\n> piterLemma p ps fp (S m) = ( ps (S m) )\n> ={ sym (consLemma ps (S m)) }=\n> ( cons (head ps) (tail ps) (S m) )\n> ={ Refl }=\n> ( (tail ps) m )\n> ={ replace {P = \\ X => (tail ps) m = (tail X) m} (pairEqElimSnd fp) Refl }=\n> ( (tail (cons (optExt ps) ps)) m )\n> ={ replace {P = \\ X => (tail (cons (optExt ps) ps)) m = (tail (cons X ps)) m} (sym (pairEqElimFst fp)) Refl }=\n> ( (tail (cons p ps)) m ) \n> ={ replace {P = \\ X => (tail (cons p ps)) m = X m} (tailLemma p ps) Refl }=\n> ( ps m )\n> ={ piterLemma p ps fp m }=\n> ( p )\n> QED\n\n> Conj : (p : Policy) -> (ps : PolicySeq) -> \n> (p, ps) `FixPoint` piter ->\n> Opt (cons p ps) \n> Conj p ps fp = opps where\n> opps : Opt (cons p ps)\n> opps = s9 where\n> s0 : (p, ps) = (optExt ps, cons (optExt ps) ps)\n> s0 = fp\n> s1 : p = optExt ps\n> s1 = pairEqElimFst s0\n> s2 : ps = cons (optExt ps) ps\n> s2 = pairEqElimSnd s0\n> s3 : ps = cons p ps\n> s3 = replace {P = \\ X => ps = cons X ps} (sym s1) s2\n> s4 : (optExt ps) `OptExt` ps\n> s4 = optExtLemma ps\n> s5 : p `OptExt` ps\n> s5 = replace {P = \\ X => X `OptExt` ps} (sym s1) s4\n> s9 : Opt (cons p ps)\n> s9 = Bellman ps ops p oep where\n> ops : Opt ps\n> ops = assert_total (replace {P = \\ X => Opt X} (sym s3) s9)\n> oep : p `OptExt` ps\n> oep = s5 \n\n\n> {-\n\n> ---}\n\n\n\n", "meta": {"hexsha": "5381d9224d7c097f9ea65348147733c01fd5e15f", "size": 8537, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "InfiniteHorizonSequentialDecisionProblems/Lala.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": "InfiniteHorizonSequentialDecisionProblems/Lala.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": "InfiniteHorizonSequentialDecisionProblems/Lala.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.0891472868, "max_line_length": 137, "alphanum_fraction": 0.5005271173, "num_tokens": 2799, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117940706734, "lm_q2_score": 0.6893056295505783, "lm_q1q2_score": 0.5698570936687736}}
{"text": "module STLC\n\nimport Pruviloj\nimport Pruviloj.Derive.DecEq\n\n%hide Abs\n%hide lookup\n\n%language ElabReflection\n%default total\n%access public export\n\ndata Typ \n = Base\n | Arrow Typ Typ\n\nShow Typ where\n show Base = \"A\"\n show (Arrow ty1 ty2) = (show ty1) ++ \"->\" ++ (show ty2)\n\nUninhabited (Base = Arrow _ _) where\n uninhabited Refl impossible\n\ndecEqTyp : (ty1, ty2 : Typ) -> Dec (ty1 = ty2)\n%runElab (deriveDecEq `{decEqTyp})\n\nDecEq Typ where\n decEq = decEqTyp\n\ndata Term \n = Var String\n | Abs String Typ Term\n | App Term Term\n\nShow Term where\n show (Var x) = x\n show (Abs x ty t) = \"\\\\\" ++ x ++ \" : \" ++ (show ty) ++ \". \" ++ (show t)\n show (App t1 t2) = (helper t1) ++ \" \" ++ (helper t2)\n where \n helper (Var x) = x\n helper t = \"(\" ++ show t ++ \")\"\ndata Value : Term -> Type where\n AbsVal : Value (Abs _ _ _)\n\nUninhabited (Value (Var _)) where\n uninhabited _ impossible\n\nUninhabited (Value (App _ _)) where\n uninhabited _ impossible\n\nCtx : Type\nCtx = List (String, Typ)\n\ndata In : (String, Typ) -> Ctx -> Type where\n Here : In (x, ty) ((x, ty)::ctx)\n There : (x = y -> Void) -> In (y, ty1) ctx -> In (y, ty1) ((x, ty2)::ctx)\n\nUninhabited (In x []) where\n uninhabited _ impossible\n\ninDrop : (x = y -> Void) -> In (x, tt1) ((y, tt2)::ctx) -> In (x, tt1) ctx\ninDrop p Here = absurd (p Refl)\ninDrop _ (There _ pi) = pi\n\nlookup : (x : String) -> (ctx : Ctx) -> Dec (ty ** In (x, ty) ctx)\nlookup _ [] = No (\\ (_ ** pi) => uninhabited pi)\nlookup x ((y, ty1) :: ctx) with (decEq x y)\n lookup x ((x, ty1) :: ctx) | (Yes Refl) = Yes (ty1 ** Here)\n | (No contra1) with (lookup x ctx) \n | (Yes (ty ** pi)) = Yes (ty ** There (contra1 . sym) pi)\n | (No contra2) = No (\\(ty1 ** pi1) => \n contra2 (ty1 ** inDrop contra1 pi1))\n\nSubset : {z : (String, Typ)} -> (ctx1, ctx2 : Ctx) -> Type\nSubset {z = z} ctx1 ctx2 = In z ctx1 -> In z ctx2\n\nsubsetNil : Subset [] ctx\nsubsetNil _ impossible\n\nsubsetCons : ({z : (String, Typ)} -> Subset {z = z} ctx1 ctx2) -> Subset ((x, ty)::ctx1) ((x, ty)::ctx2)\nsubsetCons _ Here = Here\nsubsetCons ps (There p pi) = \n There p (ps pi)\n\nsubsetDrop : Subset ((x, ty1)::(x, ty2)::ctx) ((x, ty1)::ctx)\nsubsetDrop Here = Here\nsubsetDrop (There p Here) = absurd (p Refl)\nsubsetDrop (There p (There _ pi)) = There p pi\n\nsubsetSwap : (x = y -> Void) -> Subset ((y, ty1)::(x, ty2)::ctx) ((x, ty2)::(y, ty1)::ctx)\nsubsetSwap p Here = There p Here\nsubsetSwap _ (There _ Here) = Here\nsubsetSwap _ (There p1 (There p2 pi)) = There p2 (There p1 pi)\n\ninUniqueType : In (x, ty1) ctx -> In (x, ty2) ctx -> ty1 = ty2\ninUniqueType Here Here = Refl\ninUniqueType Here (There p _) = absurd (p Refl)\ninUniqueType (There p _) Here = absurd (p Refl)\ninUniqueType (There _ pi1) (There _ pi2) = inUniqueType pi1 pi2\n\ndata Typed : Ctx -> Term -> Typ -> Type where\n TVar : In (x, ty) ctx -> Typed ctx (Var x) ty\n TAbs : Typed ((x, ty1) :: ctx) t2 ty2 -> Typed ctx (Abs x ty1 t2) (Arrow ty1 ty2)\n TApp : Typed ctx t1 (Arrow ty1 ty2) -> Typed ctx t2 ty1 -> Typed ctx (App t1 t2) ty2\n\nUninhabited (Typed [] (Var _) _) where\n uninhabited (TVar _) impossible\n\ntypedChange : Typed ctx1 t ty -> ({z : (String, Typ)} -> Subset {z = z} ctx1 ctx2) -> Typed ctx2 t ty\ntypedChange (TVar pi) ps = TVar (ps pi)\ntypedChange (TAbs pt) ps = TAbs (typedChange pt (subsetCons ps))\ntypedChange (TApp pt1 pt2) ps = \n let ih1 = typedChange pt1 ps in\n let ih2 = typedChange pt2 ps in\n TApp ih1 ih2\n\ntypedWeaken : Typed [] t ty -> Typed ctx t ty\ntypedWeaken pt = typedChange pt subsetNil\n \ntypedDrop : Typed ((x, ty1)::(x, ty2)::ctx) t ty -> Typed ((x, ty1)::ctx) t ty\ntypedDrop pt = typedChange pt subsetDrop\n \ntypedSwap : (x = y -> Void) -> Typed ((y, ty1)::(x, ty2)::ctx) t ty -> Typed ((x, ty2)::(y, ty1)::ctx) t ty\ntypedSwap pe pt = typedChange pt (subsetSwap pe)\n\ntypedUniqueType : (Typed ctx t ty1) -> (Typed ctx t ty2) -> ty1 = ty2\ntypedUniqueType (TVar pi1) (TVar pi2) = inUniqueType pi1 pi2\ntypedUniqueType (TAbs pt1) (TAbs pt2) with (typedUniqueType pt1 pt2)\n | Refl = Refl\ntypedUniqueType (TApp pt1 _) (TApp pt2 _) with (typedUniqueType pt1 pt2)\n | Refl = Refl\n\nsubst : String -> Term -> Term -> Term\nsubst x s (Var y) with (decEq x y) \n | (Yes _) = s\n | (No _) = Var y\nsubst x s (Abs y ty t) with (decEq x y) \n | (Yes _) = Abs x ty t\n | (No _) = Abs y ty (subst x s t)\nsubst x s (App t1 t2) = App (subst x s t1) (subst x s t2)\n\ndata Eval : Term -> Term -> Type where\n EApp1 : Eval t1 t1' -> Eval (App t1 t2) (App t1' t2)\n EApp2 : Value v1 -> Eval t2 t2' -> Eval (App v1 t2) (App v1 t2')\n EAppAbs : Value v2 -> t1' = subst x v2 t1 -> Eval (App (Abs x ty t1) v2) t1'\n\nprogress : (t : Term) -> Typed [] t ty -> Either (Value t) (t' ** Eval t t')\nprogress (Var _) (TVar _) impossible\nprogress (Abs _ _ _) (TAbs _) = Left AbsVal\nprogress (App t1 t2) (TApp pt1 pt2) with (progress t1 pt1) \n | (Right (t1' ** pe)) = Right ((App t1' t2) ** EApp1 pe)\n | (Left pv1) with (progress t2 pt2) \n | (Right (t2' ** pe)) = Right ((App t1 t2') ** EApp2 pv1 pe) \n | (Left pv2) with (pv1)\n progress (App (Abs x _ t) t2) _ | _ | (Left pv2) | AbsVal = \n Right (subst x t2 t ** EAppAbs pv2 Refl)\n\nsubstyyped : {x : String} -> {s : Term} -> (t : Term) -> Typed [] s ty1 -> Typed ((x, ty1) :: ctx) t ty2 -> Typed ctx (subst x s t) ty2\nsubstyyped {x=x} (Var y) pt1 pt2 with (decEq x y) \n substyyped _ pt1 (TVar Here) | (Yes Refl) = typedWeaken pt1\n substyyped _ _ (TVar (There peq _)) | (Yes Refl) = absurd (peq Refl)\n substyyped _ _ (TVar Here) | (No contra) = absurd (contra Refl)\n substyyped _ _ (TVar (There _ pi)) | (No contra) = TVar pi\nsubstyyped {x=x} (Abs y _ t) pt1 (TAbs pt2) with (decEq x y) \n substyyped _ _ (TAbs pt2) | (Yes Refl) = TAbs (typedDrop pt2)\n substyyped (Abs _ _ t) pt1 (TAbs pt2) | (No pe) = \n let ih = substyyped t pt1 (typedSwap pe pt2) in \n TAbs ih\nsubstyyped (App t1 t2) pt1 (TApp pt2 pt3) = \n let ih1 = substyyped t1 pt1 pt2 in\n let ih2 = substyyped t2 pt1 pt3 in\n TApp ih1 ih2\n\npreservation : (t : Term) -> Typed [] t ty -> Eval t t' -> Typed [] t' ty\npreservation (App t1 _) (TApp pt1 pt2) (EApp1 pe) = \n TApp (preservation t1 pt1 pe) pt2\npreservation (App (Abs _ _ _) t2) (TApp pt1 pt2) (EApp2 AbsVal pe) =\n TApp pt1 (preservation t2 pt2 pe)\npreservation (App (Abs _ _ t1) _) (TApp (TAbs pt1) pt2) (EAppAbs _ peq) = \n rewrite peq in\n substyyped t1 pt2 pt1\n\ndata LongEval : Term -> Term -> Type where\n LValue : Value v -> LongEval v v\n LEval : Eval t1 t2 -> LongEval t2 t3 -> LongEval t1 t3\n\npartial\neval' : (t : Term) -> Typed [] t ty -> (t' ** LongEval t t') \neval' t pt with (progress t pt)\n | (Left vt) = (t ** LValue vt)\n | (Right (t' ** pe)) = \n let (t2 ** ple) = eval' t' (preservation t pt pe) in\n (t2 ** LEval pe ple)\n \ntypecheckLemma : Typed ctx (App t1 t2) ty -> Typed ctx t1 (Arrow ty1 ty2) -> Typed ctx t2 ty3 -> ty1 = ty3\ntypecheckLemma (TApp pt1 pt2) pt3 pt4 with (typedUniqueType pt1 pt3) \n | Refl with (typedUniqueType pt2 pt4) \n | Refl = Refl\n\ntypecheck : (t : Term) -> (ctx : Ctx) -> Dec (ty ** Typed ctx t ty)\ntypecheck (Var x) ctx with (lookup x ctx)\n | (Yes (ty ** pi)) = Yes (ty ** TVar pi)\n | (No contra) = No (\\(ty ** TVar pi) => contra (ty ** pi))\ntypecheck (Abs x ty1 t) ctx with (typecheck t ((x, ty1)::ctx))\n | (Yes (ty2 ** pt)) = Yes (Arrow ty1 ty2 ** TAbs pt)\n | (No contra) = No (\\(Arrow _ ty4 ** TAbs pt) => contra (ty4 ** pt))\ntypecheck (App t1 t2) ctx with (typecheck t1 ctx) \n | (No contra) = No (\\(ty ** TApp pt1 _) => contra (Arrow _ ty ** pt1))\n | (Yes (Base ** pt)) = \n No (\\(_ ** TApp pt1 _) => uninhabited (typedUniqueType pt pt1))\n | (Yes (Arrow ty1 ty2 ** pt1)) with (typecheck t2 ctx)\n | (No contra) = No (\\(_ ** TApp _ pt2) => contra (_ ** pt2))\n | (Yes (ty3 ** pt2)) with (decEq ty1 ty3)\n | (No contra) = No (\\(ty ** pt3) => \n contra (typecheckLemma pt3 pt1 pt2))\n | (Yes p) = Yes (ty2 ** TApp pt1 (rewrite p in pt2))\npartial\neval : (t : Term) -> Either ((ty ** Typed [] t ty), (t' ** LongEval t t')) ((ty ** Typed [] t ty) -> Void)\neval t with (typecheck t []) \n | (Yes (ty ** pt)) = Left ((ty ** pt), (eval' t pt))\n | (No contra) = Right contra\n\npartial\nevalForget : Term-> Maybe Term\nevalForget t with (eval t)\n | Left ((_ ** _), (t' ** _)) = Just t'\n | Right _ = Nothing\n", "meta": {"hexsha": "e2bf09160b8e4d7d6653e7e16c73ed27703e27cd", "size": 8511, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/STLC.idr", "max_stars_repo_name": "Gwin73/idris-stlc", "max_stars_repo_head_hexsha": "fc715710b9f3ba8bb6746ec887dcf9eb4cc0bcfe", "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/STLC.idr", "max_issues_repo_name": "Gwin73/idris-stlc", "max_issues_repo_head_hexsha": "fc715710b9f3ba8bb6746ec887dcf9eb4cc0bcfe", "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/STLC.idr", "max_forks_repo_name": "Gwin73/idris-stlc", "max_forks_repo_head_hexsha": "fc715710b9f3ba8bb6746ec887dcf9eb4cc0bcfe", "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.3289473684, "max_line_length": 135, "alphanum_fraction": 0.581600282, "num_tokens": 3104, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707283, "lm_q2_score": 0.7401743505760728, "lm_q1q2_score": 0.5692534650147184}}
{"text": "module Main\n\nimport Control.Monad.State\nimport Data.List\nimport Data.Nat\nimport Data.Nat.Views\nimport Data.Strings\nimport Data.Vect\nimport System.File\n\nimport Data.SortedMap\nimport Text.Lexer\nimport Text.Lexer.Core\nimport Text.Parser\nimport Text.Parser.Core\nimport Text.Token\n\ndata Bit = Zero\n | One\n\nEq Bit where\n Zero == Zero = True\n One == One = True\n _ == _ = False\n\nOrd Bit where\n compare Zero Zero = EQ\n compare Zero One = LT\n compare One Zero = GT\n compare One One = EQ\n\nShow Bit where\n show Zero = \"Zero\"\n show One = \"One\"\n\nBits : Type\nBits = Vect 36 Bit\n\nrecord Mask where\n constructor MkMask\n bits : Vect 36 (Maybe Bit)\n\nShow Mask where\n show (MkMask bits) = \"Mask \" ++ show bits\n\nrecord Mem where\n constructor MkMem\n address : Nat\n value : Bits\n\nShow Mem where\n show (MkMem address value) = \"Mem \" ++ show address ++ \" \" ++ show value\n\nLine : Type\nLine = Either Mask Mem\n\nProgram : Type\nProgram = List Line\n\nMemory : Type\nMemory = SortedMap Nat Bits\n\napplyMask : Mask -> Bits -> Bits\napplyMask (MkMask maskBits) valBits = f <$> maskBits <*> valBits where\n f : Maybe Bit -> Bit -> Bit\n f Nothing x = x\n f (Just x) _ = x\n\ninitState : (Mask, Memory)\ninitState = (MkMask $ pure Nothing, empty)\n\nprogLine : Line -> State (Mask,Memory) ()\nprogLine (Left mask) = do\n (oldMask, memory) <- get\n put (mask, memory)\nprogLine (Right (MkMem address value)) = do\n (mask, oldMemory) <- get\n let memory = insert address (applyMask mask value) oldMemory\n put (mask, memory)\n\nbitsToNat : Bits -> Nat\nbitsToNat = bitsToNat' . reverse where\n bitsToNat' : Vect n Bit -> Nat\n bitsToNat' [] = 0\n bitsToNat' (One :: xs) = 1 + 2 * bitsToNat' xs\n bitsToNat' (Zero :: xs) = 0 + 2 * bitsToNat' xs\n\nintegerToBits : {n : Nat} -> Integer -> Vect n Bit\nintegerToBits x with (n)\n integerToBits x | Z = []\n integerToBits x | (S k) = if x `mod` 2 == 0\n then Zero :: integerToBits (x `div` 2)\n else One :: integerToBits (x `div` 2)\n\nnatToBits : Nat -> Bits\nnatToBits n = integerToBits $ natToInteger n\n\nMemory' : Type\nMemory' = SortedMap Bits Bits\n\ninitState' : (Mask, Memory')\ninitState' = (MkMask $ pure Nothing, empty)\n\napplyMaskToAddress' : Vect n (Maybe Bit) -> Vect n Bit -> Vect n (Maybe Bit)\napplyMaskToAddress' [] [] = []\napplyMaskToAddress' (Just Zero :: ms) (a :: as) = Just a :: applyMaskToAddress' ms as\napplyMaskToAddress' (Just One :: ms) (_ :: as) = Just One :: applyMaskToAddress' ms as\napplyMaskToAddress' (Nothing :: ms) (_ :: as) = Nothing :: applyMaskToAddress' ms as\n\nfloatingAddresses : Vect n (Maybe Bit) -> List (Vect n Bit)\nfloatingAddresses [] = pure []\nfloatingAddresses (Nothing :: xs) = (::) <$> [ Zero, One ] <*> floatingAddresses xs\nfloatingAddresses (Just x :: xs) = (x ::) <$> floatingAddresses xs\n\napplyMaskToAddress : Mask -> Bits -> List Bits\napplyMaskToAddress (MkMask mask) bs = floatingAddresses $ applyMaskToAddress' mask bs\n\ninserter : Bits -> (key : Bits) -> State (Mask,Memory') ()\ninserter value k = do\n (mask, memory) <- get\n let newMemory = insert k value memory\n put (mask, newMemory)\n\nprogLine' : Line -> State (Mask,Memory') ()\nprogLine' (Left mask) = do\n (oldMask, memory) <- get\n put (mask, memory)\nprogLine' (Right (MkMem address value)) = do\n (mask, memory) <- get\n let addresses = applyMaskToAddress mask $ natToBits address\n traverse_ (inserter value) addresses\n pure ()\n\nnamespace Parsing\n data DataKind = DKMask\n | DKMem\n | DKBracketOpen\n | DKBracketClose\n | DKSpace\n | DKEquals\n | DKNewline\n | DKNoBit\n | DKDigit\n\n Eq DataKind where\n (==) DKMask DKMask = True\n (==) DKMem DKMem = True\n (==) DKBracketOpen DKBracketOpen = True\n (==) DKBracketClose DKBracketClose = True\n (==) DKSpace DKSpace = True\n (==) DKEquals DKEquals = True\n (==) DKNewline DKNewline = True\n (==) DKNoBit DKNoBit = True\n (==) DKDigit DKDigit = True\n (==) _ _ = False\n\n export\n Show DataKind where\n show DKMask = \"DKMask\"\n show DKMem = \"DKMem\"\n show DKBracketOpen = \"DKBracketOpen\"\n show DKBracketClose = \"DKBracketClose\"\n show DKSpace = \"DKSpace\"\n show DKEquals = \"DKEquals\"\n show DKNewline = \"DKNewline\"\n show DKNoBit = \"DKNoBit\"\n show DKDigit = \"DKDigit\"\n\n data Digit = D0\n | D1\n | D2\n | D3\n | D4\n | D5\n | D6\n | D7\n | D8\n | D9\n\n Cast String Digit where\n cast \"0\" = D0\n cast \"1\" = D1\n cast \"2\" = D2\n cast \"3\" = D3\n cast \"4\" = D4\n cast \"5\" = D5\n cast \"6\" = D6\n cast \"7\" = D7\n cast \"8\" = D8\n cast \"9\" = D9\n cast _ = ?cantCastNonDigit\n\n TokenKind DataKind where\n TokType DKMask = ()\n TokType DKMem = ()\n TokType DKBracketOpen = ()\n TokType DKBracketClose = ()\n TokType DKSpace = ()\n TokType DKEquals = ()\n TokType DKNewline = ()\n TokType DKNoBit = ()\n TokType DKDigit = Digit\n tokValue DKMask _ = ()\n tokValue DKMem _ = ()\n tokValue DKBracketOpen _ = ()\n tokValue DKBracketClose _ = ()\n tokValue DKSpace _ = ()\n tokValue DKEquals _ = ()\n tokValue DKNewline _ = ()\n tokValue DKNoBit _ = ()\n tokValue DKDigit str = cast str\n\n export\n tokenMap : TokenMap $ Token DataKind\n tokenMap = toTokenMap\n [ (exact \"mask\", DKMask)\n , (exact \"mem\", DKMem)\n , (is '[', DKBracketOpen)\n , (is ']', DKBracketClose)\n , (newline, DKNewline)\n , (space, DKSpace)\n , (is '=', DKEquals)\n , (is 'X', DKNoBit)\n , (digit, DKDigit)\n ]\n\n digitsToNat : List Digit -> Nat\n digitsToNat [] = 0\n digitsToNat (x :: xs) = digitToNat x + 10 * digitsToNat xs where\n digitToNat : Digit -> Nat\n digitToNat D0 = 0\n digitToNat D1 = 1\n digitToNat D2 = 2\n digitToNat D3 = 3\n digitToNat D4 = 4\n digitToNat D5 = 5\n digitToNat D6 = 6\n digitToNat D7 = 7\n digitToNat D8 = 8\n digitToNat D9 = 9\n\n grammarMem : Grammar (Token DataKind) True Mem\n grammarMem = do\n match DKMem\n match DKBracketOpen\n digitsAddress <- some $ match DKDigit\n let address = digitsToNat $ reverse digitsAddress\n match DKBracketClose\n match DKSpace\n match DKEquals\n match DKSpace\n MkMem address <$> grammarVal where\n grammarVal : Grammar (Token DataKind) True Bits\n grammarVal = (reverse . natToBits . digitsToNat . reverse) <$> (some $ match DKDigit)\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 grammarMbBit : Grammar (Token DataKind) True (Maybe Bit)\n grammarMbBit = Just <$> grammarDig <|> grammarX where\n grammarDig : Grammar (Token DataKind) True Bit\n grammarDig = do\n n <- match DKDigit\n f n where\n f : Digit -> Grammar (Token DataKind) False Bit\n f D0 = pure Zero\n f D1 = pure One\n f _ = fail \"Can't parser bit other than 0 or 1\"\n grammarX : Grammar (Token DataKind) True (Maybe Bit)\n grammarX = match DKNoBit *> pure Nothing\n\n grammarMask : Grammar (Token DataKind) True Mask\n grammarMask = do\n match DKMask\n match DKSpace\n match DKEquals\n match DKSpace\n bits <- countExactly 36 $ grammarMbBit\n pure $ MkMask bits\n\n grammarLine : Grammar (Token DataKind) True Line\n grammarLine = (Left <$> grammarMask <|> Right <$> grammarMem) <* match DKNewline\n\n export\n grammarData : Grammar (Token DataKind) True Program\n grammarData = some grammarLine <* eof\n\nmain : IO ()\nmain = do\n inputData <- readFile \"./data\"\n case inputData of\n Left err => print err\n Right actualData => do\n let (lexed, debugLexed) = lex tokenMap actualData\n parsed = parse grammarData $ tok <$> lexed\n case parsed of\n Left (Error err restToks) => do\n print $ text <$> restToks\n print err\n Right (prog, rest) => do\n --let (endMask, endMemory) = execState initState (traverse_ progLine prog)\n let (endMask, endMemory) = execState initState' (traverse_ progLine' prog)\n print $ sum $ bitsToNat <$> endMemory\n pure ()\n pure ()\n", "meta": {"hexsha": "7e04d5da93fdcc8be766b33155c4faf1861b8ef7", "size": 8269, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "14/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": "14/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": "14/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": 26.9348534202, "max_line_length": 91, "alphanum_fraction": 0.6149473939, "num_tokens": 2479, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637433190939, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.5690311029750093}}
{"text": "module Simple\n\n%default total\n\npublic export\ndata LSys : a -> Type where\n MkLSys : List a -> (a -> List a) -> LSys a\n\niterate : Nat -> LSys a -> List a\niterate Z (MkLSys axiom _) = axiom\niterate n (MkLSys axiom rules) = go n axiom\n where\n go : Nat -> List a -> List a\n go Z word = word\n go (S n) word = let nextWord = word >>= rules\n in go n nextWord\n\n\n----------------\n-- An example --\n----------------\n\ndata Algae = A | B\n\nShow Algae where\n show A = \"A\"\n show B = \"B\"\n\nalgaeRules : Algae -> List Algae\nalgaeRules A = [A, B]\nalgaeRules B = pure A\n\nalgaeExample : LSys Algae\nalgaeExample = MkLSys [A] algaeRules\n\nmain : IO ()\nmain = print $ Simple.iterate 10 algaeExample\n", "meta": {"hexsha": "de6790177be23b5dc1778ad48f0c4deed4456528", "size": 705, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Simple.idr", "max_stars_repo_name": "PeterHajdu/ilsys", "max_stars_repo_head_hexsha": "bfaf6fef4ccef1ddcc0c2e392063ce39af7a52ce", "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": "Simple.idr", "max_issues_repo_name": "PeterHajdu/ilsys", "max_issues_repo_head_hexsha": "bfaf6fef4ccef1ddcc0c2e392063ce39af7a52ce", "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": "Simple.idr", "max_forks_repo_name": "PeterHajdu/ilsys", "max_forks_repo_head_hexsha": "bfaf6fef4ccef1ddcc0c2e392063ce39af7a52ce", "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.5526315789, "max_line_length": 49, "alphanum_fraction": 0.590070922, "num_tokens": 222, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8376199633332891, "lm_q2_score": 0.6791787121629466, "lm_q1q2_score": 0.5688936479786778}}
{"text": "module Data.List.Algebra\n\nimport Control.Algebra\nimport Data.List\n\n%default total\n\npublic export\nSemigroupV (List ty) where\n semigroupOpIsAssociative = appendAssociative\n\npublic export\nMonoidV (List ty) where\n monoidNeutralIsNeutralL = appendNilRightNeutral\n monoidNeutralIsNeutralR _ = Refl\n", "meta": {"hexsha": "c190dbb2176c46b313b36b969935fd3bd365518d", "size": 295, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/contrib/Data/List/Algebra.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/libs/contrib/Data/List/Algebra.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/libs/contrib/Data/List/Algebra.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": 18.4375, "max_line_length": 49, "alphanum_fraction": 0.8237288136, "num_tokens": 80, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8376199633332891, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.5688936425393608}}
{"text": "module DataStore\n\nimport Data.Vect\n\ninfixr 5 .+.\n\npublic export\ndata Schema = SString | SInt | (.+.) 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 _ 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", "meta": {"hexsha": "4f15b19b033e6f349867d5d80958c757139ccd03", "size": 1050, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris-exercises/DataStore.idr", "max_stars_repo_name": "0nkery/tt-tutorials", "max_stars_repo_head_hexsha": "a39926989c2f39c718893b99bd857b6d51a172b0", "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-exercises/DataStore.idr", "max_issues_repo_name": "0nkery/tt-tutorials", "max_issues_repo_head_hexsha": "a39926989c2f39c718893b99bd857b6d51a172b0", "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-exercises/DataStore.idr", "max_forks_repo_name": "0nkery/tt-tutorials", "max_forks_repo_head_hexsha": "a39926989c2f39c718893b99bd857b6d51a172b0", "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.0, "max_line_length": 90, "alphanum_fraction": 0.7238095238, "num_tokens": 291, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.6992544273261175, "lm_q1q2_score": 0.5684010708266295}}
{"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--}\nmodule BayesianOptimization.Acquisition\n\nimport public Data.Nat\nimport Distribution\nimport Tensor\nimport Data\nimport Model\nimport Optimize\nimport BayesianOptimization.Morphisms\nimport Error\n\n||| An `Empiric` constructs values from historic data and the model over that data.\n|||\n||| @features The shape of the feature domain.\n||| @out The type of the value constructed by the `Empiric`.\npublic export 0\nEmpiric : Distribution targets marginal => (0 features : Shape) -> (0 out : Type) -> Type\nEmpiric features out = Dataset features targets -> ProbabilisticModel features {marginal} -> out\n\n||| An `Acquisition` function quantifies how useful it would be to query the objective at a given \n||| set of points, towards the goal of optimizing the objective.\n|||\n||| @batch_size The number of points in the feature domain that the `Acquisition` evaluates\n||| at once.\n||| @features The shape of the feature domain.\npublic export 0\nAcquisition : (0 batch_size : Nat) -> {auto 0 _ : GT batch_size 0} -> (0 features : Shape) -> Type\nAcquisition batch_size features = Tensor (batch_size :: features) Double -> Tensor [] Double\n\n||| Construct the acquisition function that estimates the absolute improvement in the best\n||| observation if we were to evaluate the objective at a given point.\n|||\n||| @model The model over the historic data.\n||| @best The current best observation.\nexport\nexpectedImprovement : ProbabilisticModel features {marginal=Gaussian [1]} ->\n (best : Tensor [] Double) -> Acquisition 1 features\nexpectedImprovement predict best at =\n let marginal = predict at\n best' = broadcast {to=[_, 1]} best\n pdf = pdf marginal best'\n cdf = cdf marginal best'\n mean = squeeze (mean marginal)\n variance = squeeze (variance marginal)\n in (best - mean) * cdf + variance * pdf\n\n||| Build an acquisition function that returns the absolute improvement, expected by the model, in\n||| the observation value at each point.\nexport\nexpectedImprovementByModel : Empiric features {marginal=Gaussian [1]} $ Acquisition 1 features\nexpectedImprovementByModel (MkDataset query_points _) predict at =\n let best = squeeze $ reduce_min 0 $ mean $ predict query_points\n in expectedImprovement predict best at\n\n||| Build an acquisition function that returns the probability that any given point will take a\n||| value less than the specified `limit`.\nexport\nprobabilityOfFeasibility : (limit : Tensor [] Double) -> ClosedFormDistribution [1] d =>\n Empiric features {marginal=d} $ Acquisition 1 features\nprobabilityOfFeasibility limit _ predict at = cdf (predict at) $ broadcast {to=[_, 1]} limit\n\n||| Build an acquisition function that returns the negative of the lower confidence bound of the\n||| probabilistic model. The variance contribution is weighted by a factor `beta`.\n|||\n||| @beta The weighting given to the variance contribution. If negative, this function will return\n||| `Nothing`.\nexport\nnegativeLowerConfidenceBound : (beta : Double) ->\n Either ValueError $ Empiric features {marginal=Gaussian [1]} $ Acquisition 1 features\nnegativeLowerConfidenceBound beta =\n if beta < 0\n then Left $ MkValueError $ \"beta should be greater than or equal to zero, got \" ++ show beta\n else Right $ \\_, predict, at =>\n let marginal = predict at\n in squeeze $ mean marginal - const beta * variance marginal\n\n||| Build the expected improvement acquisition function in the context of a constraint on the input\n||| domain, where points that do not satisfy the constraint do not offer an improvement. The\n||| complete acquisition function is built from a constraint acquisition function, which quantifies\n||| whether specified points in the input space satisfy the constraint.\nexport\nexpectedConstrainedImprovement : (limit : Tensor [] Double) ->\n Empiric features {marginal=Gaussian [1]} $ (Acquisition 1 features -> Acquisition 1 features)\n", "meta": {"hexsha": "94d21bc95bb2eaad7318b0cf3c340d8d14dc0fcb", "size": 4469, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/BayesianOptimization/Acquisition.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/BayesianOptimization/Acquisition.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/BayesianOptimization/Acquisition.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": 45.1414141414, "max_line_length": 99, "alphanum_fraction": 0.7460281942, "num_tokens": 1030, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473879530492, "lm_q2_score": 0.6513548782017745, "lm_q1q2_score": 0.5682077266297945}}
{"text": "module Data.Optics.Iso\n\nimport Data.Optics.Prism\n\n||| Isomorphism\ndata Iso s a =\n ||| create an isomorphism between s and a\n MkIso (s -> a) (a -> s)\n\n%name Iso iso, iso1, iso2\n\n%default total\n\nto: Iso s a -> s -> a\nto (MkIso f g) s = f s\n\nfrom: Iso s a -> a -> s\nfrom (MkIso f g) a = g a\n\nmodify: (a -> a) -> (Iso s a) -> s -> s\nmodify f (MkIso to from) s = (from . f . to ) s\n\n--\n-- Compositions\n--\n\ninfixr 9 -:+\n||| compose two Isomorphisms\n(-:+): Iso a b -> Iso s a -> Iso s b\nx -:+ y = MkIso newTo newFrom\n where\n newTo: s -> b\n newTo = (to x . to y)\n newFrom: b -> s\n newFrom = (from y . from x)\n\ninfixr 9 +:-\n(+:-) : (Iso s a) -> (Iso a b) -> (Iso s b)\n(+:-) = flip (-:+)\n", "meta": {"hexsha": "775431af153d1ca1beaf56702f9576e417f8ecd3", "size": 696, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Data/Optics/Iso.idr", "max_stars_repo_name": "justjoheinz/idris-optics", "max_stars_repo_head_hexsha": "7a2dfae46ceebc78c066ec17ffd4d3f16cfa1ba9", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-10-18T23:10:49.000Z", "max_stars_repo_stars_event_max_datetime": "2015-10-19T16:59:38.000Z", "max_issues_repo_path": "Data/Optics/Iso.idr", "max_issues_repo_name": "justjoheinz/idris-optics", "max_issues_repo_head_hexsha": "7a2dfae46ceebc78c066ec17ffd4d3f16cfa1ba9", "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": "Data/Optics/Iso.idr", "max_forks_repo_name": "justjoheinz/idris-optics", "max_forks_repo_head_hexsha": "7a2dfae46ceebc78c066ec17ffd4d3f16cfa1ba9", "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.4, "max_line_length": 47, "alphanum_fraction": 0.5287356322, "num_tokens": 283, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933359135361, "lm_q2_score": 0.6926419894793246, "lm_q1q2_score": 0.5678925513479919}}
{"text": "module Linear.V\n\nimport Data.Floating\nimport Data.Void\nimport Data.Nat\nimport public Data.Vect\n\npublic export\nV : Nat -> Type -> Type\nV = Vect\n\npublic export\nT : List Nat -> Type -> Type\nT [] a = a\nT (n :: ns) a = V n (T ns a)\n\nexport\n{n : _} -> FromDouble a => FromDouble (V n a) where\n fromDouble = pure . fromDouble\n\nexport\n{n : _} -> Num a => Num (V n a) where\n (+) = zipWith (+)\n (*) = zipWith (*)\n fromInteger = pure . fromInteger\n\nexport\n{n : _} -> Neg a => Neg (V n a) where\n (-) = zipWith (-)\n negate = map negate\n\nexport\n{n : _} -> Fractional a => Fractional (V n a) where\n (/) = zipWith (/)\n recip = map recip\n\nexport\n{n : _} -> Floating a => Floating (V n a) where\n pi = pure pi\n exp = map exp\n ln = map ln\n sqrt = map sqrt\n pow = zipWith pow\n log = zipWith log\n sin = map sin\n cos = map cos\n tan = map tan\n asin = map asin\n acos = map acos\n atan = map atan\n sinh = map sinh\n cosh = map cosh\n tanh = map tanh\n\nexport\ndot : (Num a, Foldable f, Zippable f) => f a -> f a -> a\ndot x y = sum $ zipWith (*) x y\n\npunch : V i a -> V (S j) a -> V (S j) (V (i + j) a)\npunch {j = Z} xs (y :: []) = [rewrite plusZeroRightNeutral i in xs]\npunch {j = S j} xs (y :: (y' :: ys)) =\n (xs ++ (y' :: ys)) :: (rewrite sym $ plusSuccRightSucc i j in punch (xs `snoc` y) (y' :: ys))\n\nflipflop : Neg a => Bool -> V n a -> V n a\nflipflop _ [] = []\nflipflop False (x :: xs) = x :: flipflop True xs\nflipflop True (x :: xs) = negate x :: flipflop False xs\n\nexport\ndet : {n : _} -> Neg a => T [S n, S n] a -> a\ndet {n = Z} [[n]] = n\ndet {n = S n} xs = sum $ zipWith (*) (flipflop False (map head xs)) (map det $ punch [] (map tail xs))\n\nexport\neye : Num a => {n : _} -> V n (V n a)\neye {n = Z} = []\neye {n = S n} = (1 :: pure 0) :: map (0 ::) eye\n\ninfix 7 *^, ^*, *!, !*\nexport\n(*^) : (Functor f, Num a) => a -> f a -> f a\n(*^) a = map (a *)\n\nexport\n(^*) : (Functor f, Num a) => f a -> a -> f a\n(^*) = flip (*^)\n\nexport\n(*!) : (Num a, Num (f a), Functor f, Foldable f, Foldable t, Zippable t) => t a -> t (f a) -> f a\nf *! g = sum $ zipWith (*^) f g\n\nexport\n(!*) : Num a => Foldable t => Functor f => Zippable t => f (t a) -> t a -> f a\nm !* v = map (\\r => sum $ zipWith (*) r v) m\n\ninfixl 7 !*!\nexport\n(!*!) : Num a => Num (n a) => Functor m => Foldable t => Zippable t => Zippable n => Functor n => m (t a) -> t (n a) -> m (n a)\nxs !*! ys = map (\\x => foldl (+) 0 (zipWith (*^) x ys)) xs\n\nexport\nouter : (Functor f, Functor g, Num a) => f a -> g a -> f (g a)\nouter a b = map (\\x => map (* x) b) a\n\npublic export\nprod : List Nat -> Nat\nprod [] = 1\nprod (x :: xs) = x * prod xs\n\n-- multRightSuccPlus : (left : Nat) -> (right : Nat) -> left * S right = left + (left * right)\n\nexport\ngroup : (n : Nat) -> (m : Nat) -> V (n * m) a -> V n (V m a)\ngroup Z _ _ = []\ngroup (S n) m xs = let (l, r) = splitAt m xs in l :: group n m r\n\nexport\nranged : (n : _) -> T [n] Nat\nranged Z = []\nranged (S i) = Z :: map S (ranged i)\n\nexport\nbump : (size : List Nat) -> {n : _} -> {auto prf : n = prod size} -> V n a -> T size a\nbump [] {n} xs with (prf)\n bump [] {n = 1} [x] | Refl = x\nbump (m :: ms) {n} xs with (prf)\n bump (m :: ms) {n = m * prod ms} xs | Refl = map (bump ms) $ group m (prod ms) xs\n\nexport\ndump : {ns : _} -> T ns a -> V (prod ns) a\ndump {ns = []} x = [x]\ndump {ns = n :: ns} x = concat $ map dump x\n\nexport\nreshape : (size : _) -> {auto ns : _} -> {auto prf : prod ns = prod size} -> T ns a -> T size a\nreshape size = bump size . dump\n", "meta": {"hexsha": "6cfe5d18fc8791dc5bc39ea0bbb918b4fc6cb41d", "size": 3452, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Linear/V.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/Linear/V.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/Linear/V.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": 25.197080292, "max_line_length": 127, "alphanum_fraction": 0.5246234067, "num_tokens": 1341, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681049901036, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.5677763308674492}}
{"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\n\nEq a => Eq (Vect n a) where\n (==) [] [] = True\n (==) (x :: xs) (y :: ys) = x == y && xs == ys\n\nFoldable (Vect n) where\n foldr f acc [] = acc\n foldr f acc (x :: xs) = f x (foldr f acc xs)\n", "meta": {"hexsha": "73b37ae3151cd12889f6dd0b713ec2384c179d59", "size": 319, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Chapter7/Exercises/ex_7_3_2.idr", "max_stars_repo_name": "PiotrJander/TypeDD-Samples", "max_stars_repo_head_hexsha": "a5c08a13e6a6ec804171526aca10aae946588323", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 161, "max_stars_repo_stars_event_min_datetime": "2017-02-27T02:28:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-18T22:17:47.000Z", "max_issues_repo_path": "Chapter7/Exercises/ex_7_3_2.idr", "max_issues_repo_name": "gdevanla/TypeDD-Samples", "max_issues_repo_head_hexsha": "a5c08a13e6a6ec804171526aca10aae946588323", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 12, "max_issues_repo_issues_event_min_datetime": "2017-03-26T23:27:19.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-07T07:32:25.000Z", "max_forks_repo_path": "Chapter7/Exercises/ex_7_3_2.idr", "max_forks_repo_name": "gdevanla/TypeDD-Samples", "max_forks_repo_head_hexsha": "a5c08a13e6a6ec804171526aca10aae946588323", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 41, "max_forks_repo_forks_event_min_datetime": "2017-03-19T11:01:54.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-10T05:30:22.000Z", "avg_line_length": 22.7857142857, "max_line_length": 49, "alphanum_fraction": 0.4576802508, "num_tokens": 121, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8577681049901037, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.5677763251468282}}
{"text": "module PowerSource\n\ndata PowerSource = Petrol | Pedal\n\ndata Vehicle : PowerSource -> Type where\n Bicycle : Vehicle Pedal\n Unicycle : Vehicle Pedal\n Car : (fuel : Nat) -> Vehicle Petrol\n Motorbike : (fuel : Nat) -> Vehicle Petrol\n Bus : (fuel : Nat) -> Vehicle Petrol\n\nwheels : Vehicle power -> Nat\nwheels Bicycle = 2\nwheels Unicycle = 1\nwheels (Car fuel) = 4\nwheels (Bus fuel) = 4\nwheels (Motorbike fuel) = 2\n\nrefuel : Vehicle Petrol -> Vehicle Petrol\nrefuel (Car fuel) = Car 100\nrefuel (Bus fuel) = Bus 200\nrefuel (Motorbike fuel) = Motorbike 20\n-- If we add impossible to the above case, Idris will report that it is a valid case\nrefuel Bicycle impossible\n", "meta": {"hexsha": "9dfe2e96d3183c779fb2e7886712b269a31010dd", "size": 678, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "PowerSource.idr", "max_stars_repo_name": "balajisivaraman/idris-book", "max_stars_repo_head_hexsha": "2452de85e54de0242ec074a95762bde6fc4fe672", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-12-06T12:38:55.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-06T12:38:55.000Z", "max_issues_repo_path": "PowerSource.idr", "max_issues_repo_name": "balajisivaraman/idris-book", "max_issues_repo_head_hexsha": "2452de85e54de0242ec074a95762bde6fc4fe672", "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": "PowerSource.idr", "max_forks_repo_name": "balajisivaraman/idris-book", "max_forks_repo_head_hexsha": "2452de85e54de0242ec074a95762bde6fc4fe672", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-08-04T17:48:35.000Z", "max_forks_repo_forks_event_max_datetime": "2018-08-04T17:48:35.000Z", "avg_line_length": 27.12, "max_line_length": 84, "alphanum_fraction": 0.697640118, "num_tokens": 205, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920116079209, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.5677059515757994}}
{"text": "module Expr\n\nimport Maps\n\n%access public export\n\n%default total\n\nState : Type\nState = TotalMap Nat\n\nempty_state : State\nempty_state = t_empty 0\n\nA : Id\nA = MkId \"A\"\n\nB : Id\nB = MkId \"B\"\n\nC : Id\nC = MkId \"C\"\n\nD : Id\nD = MkId \"D\"\n\nE : Id\nE = MkId \"E\"\n\nF : Id\nF = MkId \"F\"\n\nW : Id\nW = MkId \"W\"\n\nX : Id\nX = MkId \"X\"\n\nY : Id\nY = MkId \"Y\"\n\nZ : Id\nZ = MkId \"Z\"\n\ndata AExp : Type where\n ANum : Nat -> AExp\n AId : Id -> AExp\n APlus : AExp -> AExp -> AExp\n AMinus : AExp -> AExp -> AExp\n AMult : AExp -> AExp -> AExp\n\nnamespace VariableNames\n A : AExp\n A = AId A\n\n B : AExp\n B = AId B\n\n C : AExp\n C = AId C\n\n D : AExp\n D = AId D\n\n E : AExp\n E = AId E\n\n F : AExp\n F = AId F\n\n W : AExp\n W = AId W\n\n X : AExp\n X = AId X\n\n Y : AExp\n Y = AId Y\n\n Z : AExp\n Z = AId Z\n\nNum AExp where\n (+) = APlus\n (*) = AMult\n fromInteger = ANum . fromIntegerNat\n\n(-) : AExp -> AExp -> AExp\n(-) = AMinus\n\nUninhabited (ANum _ = AId _) where\n uninhabited Refl impossible\n\nUninhabited (ANum _ = APlus _ _) where\n uninhabited Refl impossible\n\nUninhabited (ANum _ = AMinus _ _) where\n uninhabited Refl impossible\n\nUninhabited (ANum _ = AMult _ _) where\n uninhabited Refl impossible\n\nUninhabited (APlus _ _ = ANum _) where\n uninhabited Refl impossible\n\nUninhabited (AMinus _ _ = ANum _) where\n uninhabited Refl impossible\n\nUninhabited (AMult _ _ = ANum _) where\n uninhabited Refl impossible\n\nUninhabited (AId _ = ANum _) where\n uninhabited Refl impossible\n\nUninhabited (AId _ = APlus _ _) where\n uninhabited Refl impossible\n\nUninhabited (AId _ = AMinus _ _) where\n uninhabited Refl impossible\n\nUninhabited (AId _ = AMult _ _) where\n uninhabited Refl impossible\n\nUninhabited (APlus _ _ = AId _) where\n uninhabited Refl impossible\n\nUninhabited (AMinus _ _ = AId _) where\n uninhabited Refl impossible\n\nUninhabited (AMult _ _ = AId _) where\n uninhabited Refl impossible\n\naNumInjective : ANum n = ANum m -> n = m\naNumInjective Refl = Refl\n\naIdInjective : AId x = AId y -> x = y\naIdInjective Refl = Refl\n\ndata 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(==) : AExp -> AExp -> BExp\n(==) = BEq\n\n(<=) : AExp -> AExp -> BExp\n(<=) = BLe\n\nnot : BExp -> BExp\nnot = BNot\n\n(&&) : BExp -> BExp -> BExp\n(&&) = BAnd\n\naeval : State -> AExp -> Nat\naeval _ (ANum n) = n\naeval st (AId i) = st i\naeval st (APlus a1 a2) = aeval st a1 + aeval st a2\naeval st (AMinus a1 a2) = aeval st a1 `minus` aeval st a2\naeval st (AMult a1 a2) = aeval st a1 * aeval st a2\n\nbeval : State -> BExp -> Bool\nbeval _ BTrue = True\nbeval _ BFalse = False\nbeval st (BEq a1 a2) = aeval st a1 == aeval st a2\nbeval st (BLe a1 a2) = lte (aeval st a1) (aeval st a2)\nbeval st (BNot b) = not $ beval st b\nbeval st (BAnd b1 b2) = beval st b1 && beval st b2\n", "meta": {"hexsha": "8d19ff16b7d5bac54edc57bfca0824b0f080e119", "size": 2821, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Expr.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": "Expr.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": "Expr.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": 16.3063583815, "max_line_length": 57, "alphanum_fraction": 0.6323998582, "num_tokens": 1133, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746404, "lm_q2_score": 0.7490872187162396, "lm_q1q2_score": 0.5676540779369419}}
{"text": "module Data.Optics.Prism\n\n||| Prism\ndata Prism s a =\n MkPrism (s -> Maybe a) (a -> s)\n\n%name Prism prism, prism1, prism2\n\n%default total\n\nto : Prism s a -> (s -> Maybe a)\nto (MkPrism f g) s = f s\n\nfrom: Prism s a -> (a -> s)\nfrom (MkPrism f g) a = g a\n\ninfixr 9 <:+\n||| compose two prisms\n(<:+) : Prism a b -> Prism s a -> Prism s b\np1 <:+ p2 = MkPrism newTo newFrom\n where\n newTo: s -> Maybe b\n newTo s = case (to p2 s) of\n Nothing => Nothing\n Just a => (to p1 a)\n newFrom: b -> s\n newFrom = with Prelude.Basics (from p2 . from p1)\n\ninfixr 9 :+>\n(:+>) : Prism s a -> Prism a b -> Prism s b\n(:+>) = flip (<:+)\n\n--\n-- Functions\n--\n\n||| focus on the left of an Either\nleft: Prism (Either a b) a\nleft = MkPrism to from\n where\n to: (Either a b) -> Maybe a\n to (Left x) = Just x\n to (Right x) = Nothing\n\n from: a -> (Either a b)\n from x = Left x\n\n||| focus on the right of an Either\nright: Prism (Either a b) b\nright = MkPrism to from\n where\n to : Either a b -> Maybe b\n to (Left x) = Nothing\n to (Right x) = Just x\n\n from: b -> Either a b\n from x = Right x\n\n||| focus on Just of a Maybe\njust: Prism (Maybe a) a\njust = MkPrism to from\n where\n to: Maybe a -> Maybe a\n to Nothing = Nothing\n to (Just x) = Just x\n\n from: a -> Maybe a\n from x = Just x\n", "meta": {"hexsha": "dad164085564288fb4311bfa44159470fc715ee3", "size": 1333, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Data/Optics/Prism.idr", "max_stars_repo_name": "justjoheinz/idris-optics", "max_stars_repo_head_hexsha": "7a2dfae46ceebc78c066ec17ffd4d3f16cfa1ba9", "max_stars_repo_licenses": ["Apache-2.0"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2015-10-18T23:10:49.000Z", "max_stars_repo_stars_event_max_datetime": "2015-10-19T16:59:38.000Z", "max_issues_repo_path": "Data/Optics/Prism.idr", "max_issues_repo_name": "justjoheinz/idris-optics", "max_issues_repo_head_hexsha": "7a2dfae46ceebc78c066ec17ffd4d3f16cfa1ba9", "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": "Data/Optics/Prism.idr", "max_forks_repo_name": "justjoheinz/idris-optics", "max_forks_repo_head_hexsha": "7a2dfae46ceebc78c066ec17ffd4d3f16cfa1ba9", "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": 19.3188405797, "max_line_length": 53, "alphanum_fraction": 0.5588897224, "num_tokens": 473, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152325073083131, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.5673678451581113}}
{"text": "module Matrixes\n\nimport Data.Vect\n\nsum : Num numType => Vect rows (Vect cols numType) ->\n Vect rows (Vect cols numType) ->\n Vect rows (Vect cols numType)\n", "meta": {"hexsha": "3796409f40bea1b005b1b988058e0566919bdc26", "size": 194, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris/matrix.idr", "max_stars_repo_name": "raventid/coursera_learning", "max_stars_repo_head_hexsha": "115a03f08d30d8ba49f02c9692c289cbfb242358", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-11-28T09:26:00.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-28T09:26:00.000Z", "max_issues_repo_path": "idris/matrix.idr", "max_issues_repo_name": "raventid/coursera_learning", "max_issues_repo_head_hexsha": "115a03f08d30d8ba49f02c9692c289cbfb242358", "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/matrix.idr", "max_forks_repo_name": "raventid/coursera_learning", "max_forks_repo_head_hexsha": "115a03f08d30d8ba49f02c9692c289cbfb242358", "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.25, "max_line_length": 53, "alphanum_fraction": 0.5670103093, "num_tokens": 43, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7826624688140726, "lm_q2_score": 0.7248702761768249, "lm_q1q2_score": 0.5673287599224924}}
{"text": "module Chapter4\n\nimport TypesAndFunctions\nimport Naturality\n\n%default total\n\nExercise_4_1_1_not : Bool -> Bool\nExercise_4_1_1_not b = if b then False else True\n\nExercise_4_1_1_id : Bool -> Bool\nExercise_4_1_1_id b = b\n\nExercise_4_1_1_const_true : Bool -> Bool\nExercise_4_1_1_const_true _ = True\n\nExercise_4_1_1_const_false : Bool -> Bool\nExercise_4_1_1_const_false _ = False\n\nExercise_4_4_1_Either_a_Void_To_a : {a : Type} -> Either a Void -> a\nExercise_4_4_1_Either_a_Void_To_a (Left x) = x\nExercise_4_4_1_Either_a_Void_To_a (Right y) = void y\n\nExercise_4_4_1_a_To_Either_a_Void : {a : Type} -> a -> Either a Void\nExercise_4_4_1_a_To_Either_a_Void x = Left x\n\nExericse_4_4_1_Either_a_Void_to_a_To_Either_a_Void_id : (a : Type) ->\n IsLeftInverse\n (Exercise_4_4_1_Either_a_Void_To_a {a})\n (Exercise_4_4_1_a_To_Either_a_Void {a})\nExericse_4_4_1_Either_a_Void_to_a_To_Either_a_Void_id a (Left _) = Refl\nExericse_4_4_1_Either_a_Void_to_a_To_Either_a_Void_id a (Right _) impossible\n\nExercise_4_4_1_a_To_Either_a_Void_to_a_id : (a : Type) ->\n IsRightInverse\n (Exercise_4_4_1_Either_a_Void_To_a {a})\n (Exercise_4_4_1_a_To_Either_a_Void {a})\nExercise_4_4_1_a_To_Either_a_Void_to_a_id a _ = Refl\n\nExercise_4_4_1_are_inverses : (a : Type) ->\n IsInverse\n (Exercise_4_4_1_Either_a_Void_To_a {a})\n (Exercise_4_4_1_a_To_Either_a_Void {a})\nExercise_4_4_1_are_inverses a =\n (Exericse_4_4_1_Either_a_Void_to_a_To_Either_a_Void_id a,\n Exercise_4_4_1_a_To_Either_a_Void_to_a_id a)\n\nSumElimination : {a, b, x : Type} -> (f : a -> x) -> (g : b -> x) ->\n Either a b -> x\nSumElimination f g (Left e) = f e\nSumElimination f g (Right e) = g e\n\nCommuteSumElimination : {a, b : Type} ->\n ObserverChange {cat=TypeCategory} (Either a b) (Either b a)\nCommuteSumElimination _ h (Left e) = h (Right e)\nCommuteSumElimination _ h (Right e) = h (Left e)\n\nExercise_4_4_2_CommuteSumEliminationIsOwnInverse : {a, b : Type} ->\n IsBijectionForEach (CommuteSumElimination {a} {b})\nExercise_4_4_2_CommuteSumEliminationIsOwnInverse x =\n (CommuteSumElimination {a=b} {b=a} x **\n (\\h => functionalExtensionality (\\e => case e of\n Left _ => Refl\n Right _ => Refl),\n \\h => functionalExtensionality (\\e => case e of\n Left _ => Refl\n Right _ => Refl)))\n\nExercise_4_4_2_CommuteSumEliminationIsNatural : {a, b : Type} ->\n ObserverChangeIsNatural {cat=TypeCategory} (CommuteSumElimination {a} {b})\nExercise_4_4_2_CommuteSumEliminationIsNatural {a} {b} x y g =\n functionalExtensionality\n (\\h => functionalExtensionality\n (\\e => case e of\n Left _ => Refl\n Right _ => Refl))\n\nExercise_4_4_3_CommuteSum : {a, b : Type} -> Either a b -> Either b a\nExercise_4_4_3_CommuteSum (Left e) = Right e\nExercise_4_4_3_CommuteSum (Right e) = Left e\n\nExercise_4_4_3_CommuteSumIsOwnLeftInverse : (a, b : Type) ->\n IsLeftInverse\n (Exercise_4_4_3_CommuteSum {a} {b})\n (Exercise_4_4_3_CommuteSum {a=b} {b=a})\nExercise_4_4_3_CommuteSumIsOwnLeftInverse a b (Left _) = Refl\nExercise_4_4_3_CommuteSumIsOwnLeftInverse a b (Right _) = Refl\n\nExercise_4_4_3_CommuteSumIsOwnRightInverse : (a, b : Type) ->\n IsRightInverse\n (Exercise_4_4_3_CommuteSum {a} {b})\n (Exercise_4_4_3_CommuteSum {a=b} {b=a})\nExercise_4_4_3_CommuteSumIsOwnRightInverse a b (Left _) = Refl\nExercise_4_4_3_CommuteSumIsOwnRightInverse a b (Right _) = Refl\n\nExercise_4_4_3_CommuteSumIsOwnInverse : (a, b : Type) ->\n IsInverse\n (Exercise_4_4_3_CommuteSum {a} {b})\n (Exercise_4_4_3_CommuteSum {a=b} {b=a})\nExercise_4_4_3_CommuteSumIsOwnInverse a b =\n (Exercise_4_4_3_CommuteSumIsOwnLeftInverse a b,\n Exercise_4_4_3_CommuteSumIsOwnRightInverse a b)\n\nExercise_4_4_4_Functoriality : {a, a', b, b' : Type} ->\n (f : a -> a') -> (g : b -> b') -> ((Either a b) -> (Either a' b'))\nExercise_4_4_4_Functoriality f g (Left e) = Left (f e)\nExercise_4_4_4_Functoriality f g (Right e) = Right (g e)\n\nExercise_4_4_4_Functoriality_Preserves_Composition :\n {a, a', a'', b, b', b'' : Type} ->\n (f : a -> a') -> (f' : a' -> a'') ->\n (g : b -> b') -> (g' : b' -> b'') ->\n Exercise_4_4_4_Functoriality (f' . f) (g' . g) =\n Exercise_4_4_4_Functoriality f' g' . Exercise_4_4_4_Functoriality f g\nExercise_4_4_4_Functoriality_Preserves_Composition f f' g g' =\n functionalExtensionality\n (\\e => case e of\n Left _ => Refl\n Right _ => Refl)\n\nExercise_4_4_5_Functoriality_Preserves_Identity :\n (a, b : Type) ->\n Exercise_4_4_4_Functoriality (id {a}) (id {a=b}) = id {a=(Either a b)}\nExercise_4_4_5_Functoriality_Preserves_Identity a b =\n functionalExtensionality\n (\\e => case e of\n Left _ => Refl\n Right _ => Refl)\n", "meta": {"hexsha": "1a6c55b03bc23407dae4d7bfe7ce8246dd903875", "size": 4785, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Chapter4.idr", "max_stars_repo_name": "rokopt/dao-fp-exercises", "max_stars_repo_head_hexsha": "e5291ca45015c4ee5af49c0d8a256cf7da5b08c1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2021-01-17T17:12:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T03:52:36.000Z", "max_issues_repo_path": "src/Chapter4.idr", "max_issues_repo_name": "rokopt/dao-fp-exercises", "max_issues_repo_head_hexsha": "e5291ca45015c4ee5af49c0d8a256cf7da5b08c1", "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/Chapter4.idr", "max_forks_repo_name": "rokopt/dao-fp-exercises", "max_forks_repo_head_hexsha": "e5291ca45015c4ee5af49c0d8a256cf7da5b08c1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-17T17:12:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-17T17:12:19.000Z", "avg_line_length": 37.0930232558, "max_line_length": 78, "alphanum_fraction": 0.7003134796, "num_tokens": 1752, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390164, "lm_q2_score": 0.7662936324115011, "lm_q1q2_score": 0.5671909005047434}}
{"text": "module Toolkit.Data.Vect.Extra\n\nimport public Decidable.Equality\nimport Data.Vect\n\n%default total\n\nnamespace Equality\n public export\n vecEq : Eq type => Vect n type -> Vect m type -> Bool\n vecEq [] [] = True\n vecEq [] (x :: xs) = False\n vecEq (x :: xs) [] = False\n vecEq (x :: xs) (y :: ys) = x == y && vecEq xs ys\n\nnamespace Decidable\n namespace SameLength\n public export\n decEq : DecEq type\n => (n = m)\n -> (xs : Vect n type)\n -> (ys : Vect m type)\n -> Dec (xs = ys)\n decEq Refl xs ys with (decEq xs ys)\n decEq Refl ys ys | (Yes Refl) = Yes Refl\n decEq Refl xs ys | (No contra) = No contra\n\n namespace DiffLength\n\n public export\n vectorsDiffLength : DecEq type\n => (contra : (n = m) -> Void)\n -> {xs : Vect n type}\n -> {ys : Vect m type}\n -> (xs = ys) -> Void\n vectorsDiffLength contra Refl = contra Refl\n\n public export\n decEq : DecEq type\n => {n,m : Nat}\n -> (xs : Vect n type)\n -> (ys : Vect m type)\n -> Dec (xs = ys)\n decEq xs ys {n} {m} with (decEq n m)\n decEq xs ys {n = m} {m = m} | (Yes Refl) = decEq Refl xs ys\n decEq xs ys {n = n} {m = m} | (No contra) = No (vectorsDiffLength contra)\n\nnamespace Shape\n\n public export\n data Shape : (xs : Vect n a)\n -> (ys : Vect m a)\n -> Type\n where\n Empty : Shape Nil Nil\n LH : Shape (x::xs) Nil\n RH : Shape Nil (y::ys)\n Both : Shape (x::xs) (y::ys)\n\n export\n shape : (xs : Vect n a)\n -> (ys : Vect m a)\n -> Shape xs ys\n shape [] [] = Empty\n shape [] (y :: ys) = RH\n shape (x :: xs) [] = LH\n shape (x :: xs) (y :: ys) = Both\n\nnamespace ReplaceAt\n\n public export\n data ReplaceAt : (idx : Fin n)\n -> (xs : Vect n a)\n -> (this,that : a)\n -> (ys : Vect n a)\n -> Type\n where\n H : ReplaceAt FZ (x::xs)\n x\n y\n (y::xs)\n\n T : ReplaceAt idx xs x y ys\n -> ReplaceAt (FS idx) (x'::xs) x y (x'::ys)\n\n notSame : (x = this -> Void) -> DPair (Vect (S len) a) (ReplaceAt FZ (x :: xs) this that) -> Void\n notSame _ (MkDPair _ (T y)) impossible\n\n notLater : (DPair (Vect len a) (ReplaceAt x xs this that) -> Void) -> DPair (Vect (S len) a) (ReplaceAt (FS x) (y :: xs) this that) -> Void\n notLater f (MkDPair (y :: ys) (T z)) = f (MkDPair ys z)\n\n export\n replaceAt : DecEq a\n => (idx : Fin n)\n -> (xs : Vect n a)\n -> (this, that : a)\n -> Dec (DPair (Vect n a) (ReplaceAt idx xs this that))\n replaceAt FZ (x :: xs) this that with (decEq x this)\n replaceAt FZ (x :: xs) x that | (Yes Refl) = Yes (MkDPair (that :: xs) H)\n replaceAt FZ (x :: xs) this that | (No contra)\n = No (notSame contra)\n replaceAt (FS x) (y :: xs) this that with (replaceAt x xs this that)\n replaceAt (FS x) (y :: xs) this that | (Yes (MkDPair fst snd))\n = Yes (MkDPair (y :: fst) (T snd))\n replaceAt (FS x) (y :: xs) this that | (No contra)\n = No (notLater contra)\n\nnamespace Quantifier\n namespace AtIndex\n\n public export\n data AtIndex : (type : Type)\n -> (p : (a : type) -> Type)\n -> (idx : Fin n)\n -> (xs : Vect n type)\n -> Type\n where\n Here : (prf : p x)\n -> AtIndex type p FZ (x::xs)\n\n There : (later : AtIndex type p next xs)\n -> AtIndex type p (FS next) (not_x :: xs)\n\n export\n Uninhabited (AtIndex type p idx Nil) where\n uninhabited (Here prf) impossible\n uninhabited (There later) impossible\n\n\n notLater : (AtIndex type p y xs -> Void)\n -> AtIndex type p (FS y) (x :: xs) -> Void\n notLater f (There later) = f later\n\n notHere : (p x -> Void)\n -> AtIndex type p FZ (x :: xs) -> Void\n notHere f (Here prf) = f prf\n\n\n export\n atIndex : {type : Type}\n -> {p : type -> Type}\n -> (dec : (this : type) -> Dec (p this))\n -> (idx : Fin n)\n -> (xs : Vect n type)\n -> Dec (AtIndex type p idx xs)\n atIndex dec idx []\n = No absurd\n\n atIndex dec FZ (x :: xs) with (dec x)\n atIndex dec FZ (x :: xs) | (Yes prf)\n = Yes (Here prf)\n atIndex dec FZ (x :: xs) | (No contra)\n = No (notHere contra)\n\n\n atIndex dec (FS y) (x :: xs) with (atIndex dec y xs)\n atIndex dec (FS y) (x :: xs) | (Yes prf)\n = Yes (There prf)\n atIndex dec (FS y) (x :: xs) | (No contra)\n = No (notLater contra)\n\n namespace Diff\n public export\n data AtIndexI : (type : Type)\n -> (p : (a : type) -> Type)\n -> (m,n : Nat)\n -> (idx : Fin m)\n -> (xs : Vect n type)\n -> Type\n where\n At : AtIndex type p idx xs\n -> AtIndexI type p n n idx xs\n\n Uninhabited (AtIndexI type p m Z idx Nil) where\n uninhabited (At (Here prf)) impossible\n uninhabited (At (There later)) impossible\n\n notAtIndex : (AtIndex type p idx xs -> Void)\n -> AtIndexI type p m m idx xs -> Void\n notAtIndex f (At x) = f x\n\n indexDiffers : (m = n -> Void) -> AtIndexI type p m n idx xs -> Void\n indexDiffers f (At x) = f Refl\n\n export\n atIndexI : {type : Type}\n -> {p : type -> Type}\n -> {m,n : Nat}\n -> (dec : (this : type) -> Dec (p this))\n -> (idx : Fin m)\n -> (xs : Vect n type)\n -> Dec (AtIndexI type p m n idx xs)\n atIndexI {m} {n} dec idx xs with (decEq m n)\n atIndexI {m = m} {n = m} dec idx xs | (Yes Refl) with (atIndex dec idx xs)\n atIndexI {m = m} {n = m} dec idx xs | (Yes Refl) | (Yes prf)\n = Yes (At prf)\n\n atIndexI {m = m} {n = m} dec idx xs | (Yes Refl) | (No contra)\n = No (notAtIndex contra)\n atIndexI {m = m} {n = n} dec idx xs | (No contra)\n = No (indexDiffers contra)\n\n\n-- [ EOF ]\n", "meta": {"hexsha": "cf76922b13c4172fc76df710584b7b3e44af8918", "size": 6314, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Toolkit/Data/Vect/Extra.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/Vect/Extra.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/Vect/Extra.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": 30.8, "max_line_length": 141, "alphanum_fraction": 0.469433006, "num_tokens": 1924, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117940706734, "lm_q2_score": 0.6859494550081925, "lm_q1q2_score": 0.5670825045916235}}
{"text": "data MyNat : Type where\n MyZ : MyNat\n MyS : (1 _ : MyNat) -> MyNat\n\nlplus : (1 x : MyNat) -> (1 y : MyNat) -> MyNat\nlplus MyZ y = y\nlplus (MyS k) y = MyS (lplus k y)\n\nfoo : (1 x : MyNat) -> (1 y : MyNat) -> MyNat -> MyNat\nfoo x y z\n = let 1 test = the MyNat $ case z of\n MyZ => MyZ\n (MyS k) => MyS z\n in\n lplus test x\n", "meta": {"hexsha": "d0975a45d371fc47f89ddab9e2756c92d534856d", "size": 395, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "tests/idris2/linear007/LCase.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/linear007/LCase.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/linear007/LCase.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": 24.6875, "max_line_length": 54, "alphanum_fraction": 0.4481012658, "num_tokens": 147, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.5667395804810461}}
{"text": "module Clocks\n\n%default total\n\n-- An Idris implementation of 'A Clocked Denotational Semantics for\n-- LUCID-SYNCHRONE in COQ' by S. Boulme & G. Hamon 2001\n \nfunPower : (f : (a -> a)) -> (repeats : Nat) -> (start : a) -> a\nfunPower f Z x = x\nfunPower f (S k) x = funPower f k (f x)\n\nfunPower_commutes : (f : (a -> a)) -> (n : Nat) -> (x : a) -> (f (funPower f n x)) = (funPower f (S n) x)\nfunPower_commutes f Z x = Refl\nfunPower_commutes f (S k) x = let ff = funPower_commutes f k (f x) in\n rewrite ff in Refl\n\n\n-- nicked from bmckenna\n-- dont think we can have DecEq for streams??\n-- use equivalence instead\n-- infixl 9 =~=\n-- data Equiv : Stream a -> Stream a -> Type where\n-- Cons : (head_prf : a = b) -> Inf (Equiv as bs) -> Equiv (a :: as) (b :: bs) \n \n\n-- stream_unfold : (DecEq a) => (s : Stream a) -> Equiv s (( head s ) :: ( tail s ))\n-- stream_unfold (x :: xs) with (decEq x (head (x :: xs)))\n-- stream_unfold (x :: xs) | (Yes prf) = ?stream_unfold_rhs_1_rhs_3\n-- stream_unfold (x :: xs) | (No contra) = ?stream_unfold_rhs_1_rhs_4\n\ndata Clk = Tick | Tock\n \ndata SamplElt : (a : Type) -> Clk -> Type where\n CNone : SamplElt a Tock\n CAny : a -> SamplElt a Tick\n CFail : SamplElt a Tick\n\n\nbad_any_fail_prf : (clk : Clk) -> (CAny x = CFail) -> Void\nbad_any_fail_prf _ Refl impossible\n\nbad_fail_any_prf : (clk : Clk) -> (CFail = CAny x) -> Void\nbad_fail_any_prf _ Refl impossible\n\nbad_any_prf : (cont : (x = y) -> Void) -> (CAny x = CAny y) -> Void\nbad_any_prf cont Refl = cont Refl\n\n(DecEq a) => DecEq (SamplElt a clk) where\n decEq CNone CNone = Yes Refl\n decEq CFail CFail = Yes Refl\n decEq (CAny x) (CAny y) = case (decEq x y) of\n Yes prf => Yes (cong prf)\n No cont => No (bad_any_prf cont)\n decEq {clk=Tick} (CAny x) CFail = No (bad_any_fail_prf Tick)\n decEq {clk=Tick} CFail (CAny y) = No (bad_fail_any_prf Tick)\n \n decEq CNone CFail impossible\n decEq CFail CNone impossible\n decEq CNone (CAny y) impossible\n decEq (CAny x) CNone impossible\n \n \nClock : Type\nClock = Stream Clk\n\ndata SamplStr : (a : Type) -> (c : Clock) -> Type where\n (::) : (SamplElt a (head c)) -> Inf (SamplStr a (tail c)) -> SamplStr a c\n\n-- infixl 9 =~~=\n-- data (=~~=) : SamplStr a c -> SamplStr a c -> Type where\n-- (:::) : a = b -> Inf (as =~~= bs) -> (SPCons a as =~~= SPCons b bs)\n\nsp_hd : SamplStr a c -> SamplElt a (head c)\nsp_hd (x :: _) = x\n\nsp_tl : SamplStr a c -> SamplStr a (tail c)\nsp_tl (_ :: xs) = xs\n\n\n\nusing (c1 : Clock, c2 : Clock)\n prf_samplElt : (a : Type ) -> (c1 : Clock) -> (c2 : Clock) -> \n (head_prf : head c1 = head c2) -> \n (SamplElt a (head c1) = SamplElt a (head c2))\n prf_samplElt a c1 c2 head_prf = rewrite head_prf in Refl\n\n head_coerce : (head_prf : head c1 = head c2) -> \n (x : SamplElt a (head c1)) -> SamplElt a (head c2)\n head_coerce {a} {c1} {c2} head_prf x = let prf = prf_samplElt a c1 c2 head_prf in \n rewrite sym $ prf in x\n\n clock_coerce : (prf : c1 = c2) -> SamplStr a c1 -> SamplStr a c2\n clock_coerce Refl x = x\n\n sp_eq_clock_coerce : (prf : (c1 = c2)) -> (s : SamplStr a c1) -> (s = (clock_coerce prf s))\n sp_eq_clock_coerce Refl s = Refl\n\n-- DecEq (SamplElt a (head c)) => DecEq (SamplStr a c) where\n-- decEq (x::xs) (y::ys) with (decEq x y)\n-- decEq (x::xs) (y::ys) | Yes prf = ?DecEq_rhs_1_rhs_1\n-- decEq (x::xs) (y::ys) | No cong = No ?DecEq_rhs_1_rhs_3\n\n\n-- -- doesnt work becasue Bool is different but only one clk\n-- -- notFails : a -> Vect 2 (SamplElt a clk)\n-- -- notFails x = [CNone, CAny x]\n\n \n-- -- is_not_fail : (e : SamplElt a clk) -> Bool\n-- -- is_not_fail CNone = True\n-- -- is_not_fail (CAny x) = True\n-- -- is_not_fail CFail = False\n\n\n-- -- data WellFormed : (s : SamplStr a c) -> Type where\n-- -- IsNotFail : (prf : True = is_not_fail (sp_hd s)) -> WellFormed (sp_tl s) -> WellFormed s\n\n\ndata WellFormed : (s : SamplStr a c) -> Type where\n HeadIsAny : ((sp_hd s) = (CAny a)) -> WellFormed (sp_tl s) -> WellFormed s\n HeadIsNone : ((sp_hd s) = CNone) -> WellFormed (sp_tl s) -> WellFormed s\n \n\nelt_const : a -> (clk_value : Clk) -> SamplElt a clk_value\nelt_const x clk_value = case clk_value of \n Tick => CAny x\n Tock => CNone\n\n\nsp_const : a -> (clk : Clock) -> SamplStr a clk\nsp_const x (c :: cs) = (elt_const x c) :: (sp_const x cs)\n\n\n-- sp_const_wellformed : (x : a) -> (clk : Clock) -> WellFormed (sp_const a clk)\n-- sp_const_wellformed x (Cons c cs) = let rest = (sp_const_wellformed x cs) in \n-- case elt_const x c of\n-- CAny x' => ?head_any_prf rest\n-- CNone => ?head_non_prf\n-- CFail => ?head_fail_prf\n\nelt_extend : (SamplElt (a -> b) clk_value) -> (SamplElt a clk_value) -> (SamplElt b clk_value)\nelt_extend CNone _ = CNone\nelt_extend (CAny f) (CAny x) = CAny (f x)\nelt_extend _ CFail = CFail \nelt_extend CFail _ = CFail\n\nsp_extend : (SamplStr (a -> b) clk) -> (SamplStr a clk) -> (SamplStr b clk)\nsp_extend (f :: fs) (x :: xs) = (elt_extend f x) :: (sp_extend fs xs)\n\n\n-- sp_extend_wellformed : (fs : SamplStr (a->b) clk) -> \n-- (s : SamplStr a clk) -> \n-- (WellFormed fs) -> \n-- (WellFormed s) -> \n-- (WellFormed (sp_extend fs s)) \n-- sp_extend_wellformed fs s wf_fs wf_xs = ?sp_extend_wellformed_rhs\n\n\n-- sp_extend_const_prf : (f : a -> b) -> (x : a) -> (sp_extend (sp_const f clk) (sp_const x clk)) = sp_const (f x) clk \n-- sp_extend_const_prf f x = ?sp_extend_const_prf_rhs\n\n-- sp_extend_id_prf : (x : SamplStr a clk) -> (sp_extend (sp_const id clk) x) = x\n-- sp_extend_id_prf x = ?sp_extend_id_prf_rhs\n\n-- sp_extend_comp_prf : (f : a -> b) -> (g : b -> c) -> (x : SamplStr a clk) ->\n-- (sp_extend (sp_const g clk) (sp_extend (sp_const f clk) x)) = (sp_extend (sp_const (g . f) clk) x)\n-- sp_extend_comp_prf f g (SPCons x xs) = ?sp_extend_comp_prf_rhs_1\n\n\nflip_bool : Bool -> Bool\nflip_bool False = True\nflip_bool True = False\n\nbool_to_clk : Bool -> Clk\nbool_to_clk True = Tick\nbool_to_clk False = Tock\n\nclk_to_bool : Clk -> Bool\nclk_to_bool Tick = True\nclk_to_bool Tock = False\n\nsp_not :(SamplStr Bool clk) -> (SamplStr Bool clk)\nsp_not {clk} = sp_extend (sp_const flip_bool clk)\n\nif_then_else : Bool -> a -> a -> a\nif_then_else cond x y = if cond then x else y\n\nsp_if : SamplStr Bool clk -> SamplStr a clk -> SamplStr a clk -> SamplStr a clk\nsp_if {clk} lc x y = sp_extend (sp_extend (sp_extend (sp_const if_then_else clk) lc) x) y\n\nelt_on : SamplElt Bool clk_value -> Clk\nelt_on CNone = Tock\nelt_on (CAny x) = bool_to_clk x\nelt_on CFail = Tick\n\nsp_on : SamplStr Bool clk -> Clock\nsp_on (x :: xs) = (elt_on x) :: (sp_on xs)\n\nhead_sp_on_prf : (head (sp_on s)) = (elt_on (sp_hd s))\nhead_sp_on_prf = ?head_sp_on_prf_rhs1\n\nelt_when : (o : SamplElt Bool clk_value) -> \n SamplElt a clk_value -> \n SamplElt a (elt_on o) \nelt_when CNone e = CNone\nelt_when (CAny False) e = CNone\nelt_when (CAny True) e = e\nelt_when CFail e = CFail\n\nsp_when : (lc : SamplStr Bool clk) -> SamplStr a clk -> SamplStr a (sp_on lc)\nsp_when (c :: cs) (x :: xs) = (elt_when c x) :: (sp_when cs xs) \n\n-- flip_bool_prf : (elt_on (elt_extend (elt_const flip_bool Tick) (CAny False))) = Tick\n\n\nelt_merge : (o : SamplElt Bool clk_value) -> \n (SamplElt a (elt_on o)) -> \n (SamplElt a (elt_on (elt_extend (elt_const Clocks.flip_bool clk_value) o))) ->\n SamplElt a clk_value \nelt_merge CNone x y = CNone\nelt_merge (CAny False) x y = y\nelt_merge (CAny True) x y = x -- elt_on (CAny True)\nelt_merge CFail x y = CFail\n\nsp_merge : (lc : SamplStr Bool clk) -> \n SamplStr a (sp_on lc) -> \n SamplStr a (sp_on (sp_not lc)) -> \n SamplStr a clk\nsp_merge (c :: cs) (x :: xs) (y :: ys) = (elt_merge c x y) :: (sp_merge cs xs ?ysthings)\n -- Type mismatch between\n -- SamplElt a\n -- (head (sp_on (sp_extend (sp_const flip_bool clk)\n -- (c :: cs)))) (Type of y)\n -- and\n -- SamplElt a\n -- (elt_on (elt_extend (elt_const flip_bool (head clk))\n -- c)) (Expected type)\n\n-- (c :: cs) (x :: xs) (y :: ys) = (elt_merge c x y) :: (sp_merge cs xs ys) \n\n\n-- sp_if_equiv_prf : (lc : SamplStr Bool clk) -> (x : SamplStr a clk) -> (y : SamplStr a clk) ->\n-- (WellFormed x) ->\n-- (WellFormed y) ->\n-- (sp_if lc x y) = (sp_merge lc (sp_when lc x) (sp_when (sp_not lc) y)) \n\n-- chooses xs until clock ticks, then chooses ys\nsp_arrow : SamplStr a clk -> SamplStr a clk -> SamplStr a clk\nsp_arrow {clk = (c :: cs)} (x :: xs) (y :: ys) \n = x :: (if (clk_to_bool c) then ys else (sp_arrow xs ys))\n\n-- delay by one Clk element - if the clock ticks then initialised with init\n-- else initialise with none and recurse with rest of x :: xs\nsp_delay : (SamplStr a clk) -> (SamplElt a Tick) -> SamplStr a clk\nsp_delay {clk = (Tick :: cs)} (x :: xs) init = init :: (sp_delay xs x)\nsp_delay {clk = (Tock :: cs)} (x :: xs) init = CNone :: (sp_delay xs init)\n\nsp_pre : SamplStr a clk -> SamplStr a clk\nsp_pre s = sp_delay s CFail \n\nsp_fby : SamplStr a clk -> SamplStr a clk -> SamplStr a clk\nsp_fby x y = sp_arrow x (sp_pre y)\n\n-- arrow_equiv_prf : (x : SamplStr a clk) -> (y : SamplStr a clk) -> \n-- WellFormed x -> WellFormed y ->\n-- (sp_arrow x y) = (sp_if (sp_fby (sp_const True clk) (sp_const False clk)) x y)\n", "meta": {"hexsha": "cb831da9bc3aa5d76b03cc83e6dedac737cd9eab", "size": 9899, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "clocks.idr", "max_stars_repo_name": "wyn/incremental", "max_stars_repo_head_hexsha": "eee2b612f1f403957fe1793fe8fe04f56c337e4f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-05-02T22:33:50.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-26T17:50:38.000Z", "max_issues_repo_path": "clocks.idr", "max_issues_repo_name": "wyn/incremental", "max_issues_repo_head_hexsha": "eee2b612f1f403957fe1793fe8fe04f56c337e4f", "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": "clocks.idr", "max_forks_repo_name": "wyn/incremental", "max_forks_repo_head_hexsha": "eee2b612f1f403957fe1793fe8fe04f56c337e4f", "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.074906367, "max_line_length": 122, "alphanum_fraction": 0.5756136984, "num_tokens": 3358, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8104788995148791, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.566730963819741}}
{"text": "%default partial\n\ndata Vect : Nat -> Type -> Type where\n Nil : Vect Z a\n (::) : a -> Vect k a -> Vect (S k) a\n\nzip : Vect n a -> Vect n b -> Vect n (a, b)\nzip [] [] impossible\nzip (x :: xs) (y :: ys) = (x, y) :: zip xs ys\n", "meta": {"hexsha": "8fd1ffebee6b7b43de278d6f53798f121aac55bb", "size": 231, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "tests/idris2/coverage001/Vect2.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/coverage001/Vect2.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/coverage001/Vect2.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": 23.1, "max_line_length": 45, "alphanum_fraction": 0.4935064935, "num_tokens": 83, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8104788903594354, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.566730947258632}}
{"text": "module Data.Logic.Propositional\n\n%default total\n\n-- Idris uses intuitionistic logic, so it does not validate the\n-- principle of excluded middle (PEM) or similar theorems of classical\n-- logic. But it does validate certain relations among these\n-- propositions, and that's what's in this file.\n\n||| The principle of excluded middle\nPEM : Type -> Type\nPEM p = Either p (Not p)\n\n||| Double negation elimination\nDNE : Type -> Type\nDNE p = Not $ Not p -> p\n\n||| The consensus theorem (at least, the interesting part)\nConsensus : Type -> Type -> Type -> Type\nConsensus p q r = (q, r) -> Either (p, q) (Not p, r)\n\n||| Peirce's law\nPeirce : Type -> Type -> Type\nPeirce p q = ((p -> q) -> p) -> p\n\n||| Not sure if this one has a name, so call it Frege's law\nFrege : Type -> Type -> Type -> Type\nFrege p q r = (p -> r) -> (q -> r) -> ((p -> q) -> q) -> r\n\n||| The converse of contraposition: (p -> q) -> Not q -> Not p\nTransposition : Type -> Type -> Type\nTransposition p q = (Not q -> Not p) -> p -> q\n\n||| This isn't a good name.\nSwitch : Type -> Type\nSwitch p = (Not p -> p) -> p\n\n-- PEM and the others can't be proved outright, but it is possible to\n-- prove the double negations (DN) of all of them.\n\n||| The double negation of a proposition\nDN : Type -> Type\nDN p = Not $ Not p\n\npemDN : DN $ PEM p\npemDN f = f $ Right $ \\x => f $ Left x\n\ndneDN : DN $ DNE p\ndneDN f = f $ \\g => void $ g $ \\x => f $ \\_ => x\n\nconsensusDN : DN $ Consensus p q r\nconsensusDN f = f $ \\(y, z) => Right (\\x => f $ \\(_, _) => Left (x, y), z)\n\npeirceDN : DN $ Peirce p q\npeirceDN f = f $ \\g => g $ \\x => void $ f $ \\_ => x\n\nfregeDN : DN $ Frege p q r\nfregeDN f = f $ \\g, h, i => h $ i $ \\x => void $ f $ \\_, _, _ => g x\n\ntranspositionDN : DN $ Transposition p q\ntranspositionDN f = f $ \\g, x => void $ g (\\y => f $ \\_, _ => y) x\n\nswitchDN : DN $ Switch p\nswitchDN f = f $ \\g => g $ \\x => f $ \\_ => x\n\n-- It's easy to prove all these theorems assuming PEM.\n\ndnePEM : PEM p -> DNE p\ndnePEM (Left l) _ = l\ndnePEM (Right r) f = void $ f r\n\nconsensusPEM : PEM p -> Consensus p q r\nconsensusPEM (Left l) (y, _) = Left (l, y)\nconsensusPEM (Right r) (_, z) = Right (r, z)\n\npeircePEM : PEM p -> Peirce p q\npeircePEM (Left l) _ = l\npeircePEM (Right r) f = f $ \\x => void $ r x\n\nfregePEM : PEM p -> Frege p q r\nfregePEM (Left l) f _ _ = f l\nfregePEM (Right r) _ g h = g $ h $ \\x => void $ r x\n\ntranspositionPEM : PEM p -> Transposition q p\ntranspositionPEM (Left l) _ _ = l\ntranspositionPEM (Right r) f x = void $ f r x\n\nswitchPEM : PEM p -> Switch p\nswitchPEM (Left l) _ = l\nswitchPEM (Right r) f = f r\n\n-- It's trivial to prove these theorems assuming double negation\n-- elimination (DNE), since their double negations can all be proved.\n\n||| Eliminate double negations\nEDN : DN p -> DNE p -> p\nEDN f g = g f\n\npemDNE : DNE $ PEM p -> PEM p\npemDNE = EDN pemDN\n\n-- It's possible to prove the theorems assuming Peirce's law, but some\n-- thought must be given to choosing the right instances. Peirce's law\n-- is therefore weaker than PEM on an instance-by-instance basis, but\n-- all the instances together are equivalent.\n\npemPeirce : Peirce (PEM p) Void -> PEM p\npemPeirce f = f $ \\g => Right $ \\x => g $ Left x\n\ndnePeirce : Peirce p Void -> DNE p\ndnePeirce f g = f $ \\h => void $ g h\n\nconsensusPeirce : Peirce (Consensus p q r) Void -> Consensus p q r\nconsensusPeirce f (y, z) =\n f (\\g, (_, _) => Right (\\x => g (\\_ => Left (x, y)), z)) (y, z)\n\nfregePeirce : Peirce (Frege p q r) Void -> Frege p q r\nfregePeirce f g h i =\n f (\\j, _, _, _ => h $ i $ \\x => void $ j $ \\_, _, _ => g x) g h i\n\ntranspositionPeirce : Peirce (Transposition p q) Void -> Transposition p q\ntranspositionPeirce f g x =\n f (\\h, _, _ => void $ g (\\y => h $ \\_, _ => y) x) (\\j, _ => g j x) x\n\n-- There are a variety of single axioms sufficient for deriving all of\n-- classical logic. The earliest of these is known as Nicod's axiom,\n-- but it is written using only nand operators and doesn't lend itself\n-- to Idris's type system. Meredith's axiom, on the other hand, is\n-- written using implication and negation.\n\n||| Meredith's axiom, sufficient for deriving all of classical logic\nMeredith : (p, q, r, s, t : Type) -> Type\nMeredith p q r s t =\n ((((p -> q) -> Not r -> Not s) -> r) -> t) -> (t -> p) -> s -> p\n\n-- The Meredith axiom implies all of classical logic, and so in\n-- particular it implies PEM, and therefore cannot be proved in\n-- intuitionistic logic. As usual, however, its double negation can be\n-- proved.\n\nmeredithDN : DN $ Meredith p q r s t\nmeredithDN f =\n f $ \\g, h, x =>\n h $ g $ \\i =>\n void $ i\n (\\y => void $ f $ \\_, _, _ => y)\n (\\z => f $ \\_, _, _ => h $ g $ \\_ => z)\n x\n\n-- Meredith can be proved assuming PEM, since the type system itself\n-- takes care of the rest.\n\nmeredithPEM : PEM p -> Meredith p q r s t\nmeredithPEM (Left l) _ _ _ = l\nmeredithPEM (Right r) f g x =\n g $ f $ \\h =>\n void $ h\n (\\y => void $ r y)\n (\\z => r $ g $ f (\\_ => z))\n x\n", "meta": {"hexsha": "55d7941ab8f0208f4d5b3d1b0dd3b8b8ffcfb3b7", "size": 4959, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/contrib/Data/Logic/Propositional.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/contrib/Data/Logic/Propositional.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/contrib/Data/Logic/Propositional.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.801242236, "max_line_length": 74, "alphanum_fraction": 0.6075821738, "num_tokens": 1715, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.7185943985973773, "lm_q1q2_score": 0.5662029436691184}}
{"text": "||| An approach to intrinsically-typed STLC with Type Synonyms and New types.\n|||\n||| We treat type 'aliases' and 'newtypes' as term level constructs,\n||| which ensures named types can be differentiated by name i.e. De\n||| Bruijn indices. Type universes are used to separate descriptions\n||| of how types are formed and their use to type values.\n|||\n||| Standard constructions are used to represent the language as an\n||| EDSL, together with proof of progress taken from PLFA Part 2.\n|||\n||| This module compliments Section 5 of the Functional Pearl.\n|||\n||| Although the code appears to be total, there is a known issues\n||| with Idris2 totality checker that causes it to slow down when\n||| dealing with mutually defined terms.\n|||\nmodule Razor.LetFoo\n\nimport Razor.Common\n\n%default covering\n\nnamespace Types\n\n ||| Levels at which types and their types are defined in our type\n ||| universes.\n public export\n data Level = TYPE -- Build types here\n | VALUE -- Use types here.\n\n ||| Our types are meta types...\n public export\n data MTy : Level -> Type where\n\n -- Explicit Type formers\n IntTyDesc : MTy TYPE\n IntTy : MTy VALUE\n\n CharTyDesc : MTy TYPE\n CharTy : MTy VALUE\n\n -- Implicit constructions.\n NewtypeTy : MTy level -> MTy level\n\n ||| A predicate to type check types against type formers.\n public export\n data TyCheck : (type : MTy TYPE)\n -> (value : MTy VALUE)\n -> Type\n where\n ChkInt : TyCheck IntTyDesc IntTy\n ChkChar : TyCheck CharTyDesc CharTy\n\n ChkNewtype : TyCheck innerType innerValue\n -> TyCheck (NewtypeTy innerType)\n (NewtypeTy innerValue)\n\n\n ||| A context is a list of types in different universes.\n public export\n Context : List Level -> Type\n Context = DList Level MTy\n\n public export\n Elem : Context lvls -> MTy level -> Type\n Elem g ty = Elem Level MTy ty g\n\nnamespace Terms\n\n public export\n data SystemFoo : Context lvls -> MTy level -> Type where\n -- STLC\n\n Var : Elem Level MTy type ctxt -> SystemFoo ctxt type\n\n -- Type Constructors\n TyInt : SystemFoo ctxt IntTyDesc\n TyChar : SystemFoo ctxt CharTyDesc\n\n -- Type Ascriptions\n The : { mtypeType : MTy TYPE}\n -> { mtypeValue : MTy VALUE}\n -> ( type : SystemFoo ctxt mtypeType)\n -> ( value : SystemFoo ctxt mtypeValue)\n -> (0 prf : TyCheck mtypeType mtypeValue)\n -> SystemFoo ctxt mtypeValue\n\n -- Base Values\n\n I : Int -> SystemFoo ctxt IntTy\n C : Char -> SystemFoo ctxt CharTy\n\n -- NewType Type & Value Constructors, and Matching.\n TyCTor : {type : MTy TYPE}\n -> (desc : SystemFoo ctxt type)\n -> SystemFoo ctxt (NewtypeTy type)\n\n CTor : {typeM : MTy TYPE}\n -> {typeV : MTy VALUE}\n -> ( type : SystemFoo ctxt (NewtypeTy typeM))\n -> ( value : SystemFoo ctxt typeV)\n -> (0 prf : TyCheck typeM typeV)\n -> SystemFoo ctxt (NewtypeTy typeV)\n\n Match : {type : MTy VALUE}\n -> {bodyTy : MTy VALUE}\n -> (value : SystemFoo ctxt (NewtypeTy type))\n -> (body : SystemFoo (ctxt += type) bodyTy)\n -> SystemFoo ctxt bodyTy\n\n -- Binders\n Let : { exprTy, bodyType : MTy VALUE}\n -> ( value : SystemFoo ctxt exprTy)\n -> ( body : SystemFoo (ctxt += exprTy) bodyType)\n -> SystemFoo ctxt bodyType\n\n NewType : {lvl : Level}\n -> {type : MTy TYPE}\n -> {bodyType : MTy lvl}\n -> (desc : SystemFoo ctxt (NewtypeTy type))\n -> (body : SystemFoo (ctxt += (NewtypeTy type)) bodyType)\n -> SystemFoo ctxt bodyType\n\n TypeAlias : {lvl : Level}\n -> {type : MTy TYPE}\n -> {bodyTy : MTy lvl}\n -> (desc : SystemFoo ctxt type)\n -> (body : SystemFoo (ctxt += type) bodyTy)\n -> SystemFoo ctxt bodyTy\n\n\nnamespace Renaming\n\n public export\n weaken : (func : Types.Elem old type\n -> Types.Elem new type)\n -> (Elem (old += type') type\n -> Types.Elem (new += type') type)\n\n weaken func Here = Here\n weaken func (There rest) = There (func rest)\n\n public export\n rename : (f : {level : Level}\n -> {type : MTy level}\n -> Types.Elem old type\n -> Types.Elem new type)\n -> ({level : Level}\n -> {type : MTy level}\n -> SystemFoo old type\n -> SystemFoo new type)\n\n -- STLC\n rename f (Var idx) = Var (f idx)\n\n -- Type Constructors\n rename f TyInt = TyInt\n rename f TyChar = TyChar\n\n -- Type Ascriptions\n rename f (The type value prf) = The (rename f type)\n (rename f value)\n prf\n -- Base Values\n rename f (I i) = (I i)\n rename f (C c) = (C c)\n\n -- NewType Type & Value Constructors, and Matching.\n rename f (TyCTor desc) = TyCTor (rename f desc)\n\n rename f (CTor type value prf)\n = CTor (rename f type)\n (rename f value)\n prf\n\n rename f (Match scrutinee body)\n = Match (rename f scrutinee)\n (rename (weaken f) body)\n\n -- Binders\n rename f (Let expr body)\n = Let (rename f expr)\n (rename (weaken f) body)\n\n rename f (NewType type body)\n = NewType (rename f type)\n (rename (weaken f) body)\n\n rename f (TypeAlias type body)\n = TypeAlias (rename f type)\n (rename (weaken f) body)\n\nnamespace Substitution\n public export\n weakens : (f : {level : Level}\n -> {type : MTy level}\n -> Types.Elem old type\n -> SystemFoo new type)\n -> ({level : Level}\n -> {type : MTy level}\n -> Types.Elem (old += type') type\n -> SystemFoo (new += type') type)\n weakens f Here = Var Here\n weakens f (There rest) = rename There (f rest)\n\n -- general substitute\n namespace General\n public export\n subst : (f : {level : Level}\n -> {type : MTy level}\n -> Types.Elem old type\n -> SystemFoo new type)\n -> ({level : Level}\n -> {type : MTy level}\n -> SystemFoo old type\n -> SystemFoo new type)\n\n -- STLC\n subst f (Var idx) = f idx\n\n -- Types\n subst f TyInt = TyInt\n subst f TyChar = TyChar\n\n -- Type Ascriptions\n subst f (The type value prf)\n = The (subst f type)\n (subst f value)\n prf\n\n -- Base Values\n subst f (I i) = (I i)\n subst f (C c) = (C c)\n\n -- NewType Type & Value Constructors, and Matching.\n subst f (Match scrutinee body)\n = Match (subst f scrutinee) (subst (weakens f) body)\n\n subst f (CTor type value prf)\n = CTor (subst f type) (subst f value) prf\n\n subst f (TyCTor desc) = TyCTor (subst f desc)\n\n -- Bindings\n subst f (Let expr body)\n = Let (subst f expr)\n (subst (weakens f) body)\n\n subst f (NewType desc body)\n = NewType (subst f desc) (subst (weakens f) body)\n\n subst f (TypeAlias type body)\n = TypeAlias (subst f type) (subst (weakens f) body)\n\n namespace Single\n public export\n apply : {levelA : Level}\n -> {typeA : MTy levelA}\n -> (this : SystemFoo ctxt typeB)\n -> (idx : Elem (ctxt += typeB) typeA)\n -> SystemFoo ctxt typeA\n apply this Here = this\n apply this (There rest) = Var rest\n\n public export\n subst : {levelA,levelB : Level}\n -> {typeA : MTy levelA}\n -> {typeB : MTy levelB}\n -> (this : SystemFoo ctxt typeB)\n -> (inThis : SystemFoo (ctxt += typeB) typeA)\n -> SystemFoo ctxt typeA\n subst {ctxt} {typeA} {typeB} {levelA} {levelB} this inThis\n = General.subst (apply this) inThis\n\n\nnamespace Values\n\n public export\n data Value : SystemFoo ctxt type -> Type where\n TyCharV : Value TyChar\n TyIntV : Value TyInt\n\n TyCTorV : Value desc -> Value (TyCTor desc)\n CTorV : Value value -> Value (CTor type value prf)\n\n IntV : Value (I i)\n CharV : Value (C c)\n\nnamespace Reduction\n\n public export\n data Redux : (this : SystemFoo ctxt type)\n -> (that : SystemFoo ctxt type)\n -> Type\n where\n\n -- Ascriptions\n SimplifyTheType : (type : Redux this that)\n -> Redux (The this value prf)\n (The that value prf)\n\n SimplifyTheValue : {this, that : SystemFoo ctxt vtype}\n -> {type : SystemFoo ctxt ttype}\n -> (prf : Value type)\n -> (value : Redux this that)\n -> Redux (The type this prf')\n (The type that prf')\n\n ReduceThe : {type : SystemFoo ctxt ttype}\n -> {value : SystemFoo ctxt vtype}\n -> (typeVal : Value type)\n -> (valueVal : Value value)\n -> Redux (The type value prf)\n value\n\n -- Matching newtypes\n SimplifyTyCTor : (desc : Redux this that)\n -> Redux (TyCTor this) (TyCTor that)\n\n SimplifyCTorType : {this, that : SystemFoo ctxt (NewtypeTy typeM)}\n -> {value : SystemFoo ctxt type}\n -> (theType : Redux this that)\n -> Redux (CTor this value prf)\n (CTor that value prf)\n\n SimplifyCTorValue : {this, that : SystemFoo ctxt typeV}\n -> {theType : SystemFoo ctxt (NewtypeTy typeD)}\n -> (typeV : Value theType)\n -> (value : Redux this that)\n -> Redux (CTor theType this prf)\n (CTor theType that prf)\n\n SimplifyMatchScrut : {this, that : SystemFoo ctxt (NewtypeTy stype)}\n -> {body : SystemFoo (ctxt += stype) btype}\n -> (scutinee : Redux this that)\n -> Redux (Match this body)\n (Match that body)\n\n ReduceMatchBody : {type : SystemFoo ctxt (NewtypeTy ttype)}\n -> {value : SystemFoo ctxt vtype}\n -> {body : SystemFoo (ctxt += vtype) btype}\n -> (valueVal : Value value)\n -> Redux (Match (CTor type value prf) body)\n (subst value body)\n\n -- Let binding\n SimplifyLetValue : {this, that : SystemFoo ctxt typeV}\n -> {body : SystemFoo (ctxt += typeV) typeB}\n -> (value : Redux this that)\n -> Redux (Let this body)\n (Let that body)\n\n ReduceLetBody : {value : SystemFoo ctxt typeV}\n -> {body : SystemFoo (ctxt += typeV) typeB}\n -> (valueVal : Value value)\n -> Redux (Let value body)\n (subst value body)\n\n -- Newtypes\n\n SimplifyNewType : {this, that : SystemFoo ctxt (NewtypeTy typeV)}\n -> {body : SystemFoo (ctxt += (NewtypeTy typeV)) typeB}\n -> (desc : Redux this that)\n -> Redux (NewType this body)\n (NewType that body)\n\n ReduceNewType : {typeD : MTy TYPE}\n -> {desc : SystemFoo ctxt (NewtypeTy typeD)}\n -> {body : SystemFoo (ctxt += (NewtypeTy typeD)) typeB}\n -> (value : Value desc)\n -> Redux (NewType desc body)\n (subst desc body)\n\n SimplifyTypeAlias : {this, that : SystemFoo ctxt typeV}\n -> {body : SystemFoo (ctxt += typeV) typeB}\n -> (desc : Redux this that)\n -> Redux (TypeAlias this body) (TypeAlias that body)\n\n ReduceTypeAlias : {desc : SystemFoo ctxt typeD}\n -> {body : SystemFoo (ctxt += typeD) typeB}\n -> (descVal : Value desc)\n -> Redux (TypeAlias desc body)\n (subst desc body)\n\n\nnamespace Progress\n public export\n data Progress : (term : SystemFoo Nil type)\n -> Type\n where\n Done : forall mty . {term : SystemFoo Nil mty}\n -> Value term\n -> Progress term\n Step : {this, that : SystemFoo Nil type}\n -> (prf : Redux this that)\n -> Progress this\n\n public export\n progress : (term : SystemFoo Nil type)\n -> Progress term\n progress {type} (Var _) impossible\n\n\n -- Type Constructors\n progress TyInt = Done TyIntV\n progress TyChar = Done TyCharV\n\n progress (The type value prf) with (progress type)\n progress (The type value prf) | (Done valueT) with (progress value)\n progress (The type value prf) | (Done valueT) | (Done valueV)\n = Step (ReduceThe valueT valueV)\n progress (The type value prf) | (Done valueT) | (Step prfV)\n = Step (SimplifyTheValue valueT prfV)\n progress (The type value prf) | (Step prfT)\n = Step (SimplifyTheType prfT)\n\n -- Base Values\n progress (I i) = Done IntV\n progress (C c) = Done CharV\n\n -- NewType Type & Value Constructors, and Matching.\n progress (TyCTor type) with (progress type)\n progress (TyCTor type) | (Done valueT) = Done (TyCTorV valueT)\n progress (TyCTor type) | (Step prfT) = Step (SimplifyTyCTor prfT)\n\n progress (CTor type value prf) with (progress type)\n progress (CTor type value prf) | (Done valueT) with (progress value)\n progress (CTor type value prf) | (Done valueT) | (Done valueV)\n = Done (CTorV valueV)\n progress (CTor type value prf) | (Done valueT) | (Step prfV)\n = Step (SimplifyCTorValue valueT prfV)\n progress (CTor type value prf) | (Step prfT)\n = Step (SimplifyCTorType prfT)\n\n progress (Match scrutinee body) with (progress scrutinee)\n progress (Match (CTor type' value prf) body) | (Done (CTorV valueV))\n = Step (ReduceMatchBody valueV)\n progress (Match scrutinee body) | (Step prfS)\n = Step (SimplifyMatchScrut prfS)\n\n -- Binders\n progress (Let value body) with (progress value)\n progress (Let value body) | (Done valueV)\n = Step (ReduceLetBody valueV)\n progress (Let value body) | (Step prfV)\n = Step (SimplifyLetValue prfV)\n\n progress (NewType desc body) with (progress desc)\n progress (NewType desc body) | (Done valueD)\n = Step (ReduceNewType valueD)\n progress (NewType desc body) | (Step prfD)\n = Step (SimplifyNewType prfD)\n\n progress (TypeAlias desc body) with (progress desc)\n progress (TypeAlias desc body) | (Done valueD)\n = Step (ReduceTypeAlias valueD)\n progress (TypeAlias desc body) | (Step prfD)\n = Step (SimplifyTypeAlias prfD)\n\nnamespace Evaluation\n\n public export\n data Reduces : (this : SystemFoo ctxt type)\n -> (that : SystemFoo ctxt type)\n -> Type\n where\n Refl : {this : SystemFoo ctxt type}\n -> Reduces this this\n\n Trans : {this, that, end : SystemFoo ctxt type}\n -> Redux this that\n -> Reduces that end\n -> Reduces this end\n\n public export\n data Finished : (term : SystemFoo ctxt type)\n -> Type\n where\n Normalised : {term : SystemFoo ctxt type}\n -> Value term\n -> Finished term\n OOF : Finished term\n\n public export\n data Evaluate : (term : SystemFoo Nil type) -> Type where\n RunEval : {this, that : SystemFoo 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 : forall type\n . (fuel : Fuel)\n -> (term : SystemFoo 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 : forall type\n . (this : SystemFoo Nil type)\n -> Maybe (Subset (SystemFoo 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-- namespace Example\n\n\n-- --------------------------------------------------------------------- [ EOF ]\n", "meta": {"hexsha": "38af075a8d6c243ece408bb4c3b4a9be5390a978", "size": 17462, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Razor/LetFoo.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/LetFoo.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/LetFoo.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.260952381, "max_line_length": 83, "alphanum_fraction": 0.5296644142, "num_tokens": 4354, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8418256591565729, "lm_q2_score": 0.6723316860482763, "lm_q1q2_score": 0.5659860647794402}}
{"text": "||| The telescope data structures.\n|||\n||| Indexing telescopes by their length (hopefully) helps inform the\n||| type-checker during inference.\nmodule Data.Telescope.Telescope\n\nimport Data.DPair\nimport Data.Nat\nimport Data.Fin\n\n%default total\n\npublic export\nplusAcc : Nat -> Nat -> Nat\nplusAcc Z n = n\nplusAcc (S m) n = plusAcc m (S n)\n\nexport\nplusAccIsPlus : (m, n : Nat) -> (m + n) === plusAcc m n\nplusAccIsPlus Z n = Refl\nplusAccIsPlus (S m) n =\n rewrite plusSuccRightSucc m n in\n plusAccIsPlus m (S n)\n\npublic export\nplusAccZeroRightNeutral : (m : Nat) -> plusAcc m 0 === m\nplusAccZeroRightNeutral m =\n rewrite sym (plusAccIsPlus m 0) in\n rewrite plusZeroRightNeutral m in\n Refl\n\n\ninfixl 4 -.\ninfixr 4 .-\n\nnamespace Left\n\n mutual\n ||| A left-nested sequence of dependent types\n public export\n data Telescope : (k : Nat) -> Type where\n Nil : Telescope 0\n (-.) : (gamma : Left.Telescope k) -> (ty : TypeIn gamma) -> Telescope (S k)\n\n ||| A type with dependencies in the given context\n public export\n TypeIn : Left.Telescope k -> Type\n TypeIn gamma = (env : Environment gamma) -> Type\n\n ||| A tuple of values of each type in the telescope\n public export\n Environment : Left.Telescope k -> Type\n Environment [] = ()\n Environment (gamma -. ty) = (env : Environment gamma ** ty env)\n\n export\n weakenTypeIn : TypeIn gamma -> TypeIn (gamma -. sigma)\n weakenTypeIn ty env = ty (fst env)\n\n public export\n uncons : (gamma : Telescope (S k)) ->\n (ty : Type\n ** delta : (ty -> Telescope k)\n ** (v : ty) -> Environment (delta v) -> Environment gamma)\n uncons ([] -. ty) = (ty () ** const [] ** \\ v, _ => (() ** v))\n uncons (gamma@(_ -. _) -. ty) =\n let (sigma ** delta ** left) = uncons gamma in\n (sigma ** (\\ v => delta v -. (\\ env => ty (left v env)))\n ** (\\ v, (env ** w) => (left v env ** w)))\n\n public export\n (++) : {n : Nat} -> (gamma : Left.Telescope m) -> (Environment gamma -> Left.Telescope n) ->\n Telescope (plusAcc n m)\n (++) {n = Z} gamma delta = gamma\n (++) {n = S n} gamma delta = (gamma -. sigma) ++ uncurry theta where\n\n sigma : Environment gamma -> Type\n sigma env = fst (uncons (delta env))\n\n theta : (env : Environment gamma) -> sigma env -> Telescope n\n theta env val with (uncons (delta env))\n theta env val | (sig ** omega ** _) = omega val\n\n public export\n cons : {k : Nat} -> (ty : Type) -> (ty -> Left.Telescope k) -> Left.Telescope (S k)\n cons sigma gamma =\n rewrite plusCommutative 1 k in\n rewrite plusAccIsPlus k 1 in\n ([] -. const sigma) ++ (gamma . snd)\n\n ||| A position between the variables of a telescope, counting from the _end_:\n ||| Telescope: Nil -. ty1 -. ... -. tyn\n ||| Positions: ^k ^k-1 ^k-2 ^1 ^0\n public export\n Position : {k : Nat} -> Telescope k -> Type\n Position {k} _ = Fin (S k)\n\n ||| The position at the beginning of the telescope\n public export\n start : {k : Nat} -> (gamma : Telescope k) -> Position gamma\n start {k} gamma = last\n\nnamespace Right\n\n mutual\n ||| A right-nested sequence of dependent types\n public export\n data Telescope : (k : Nat) -> Type where\n Nil : Telescope 0\n (.-) : (ty : Type) -> (gamma : ty -> Right.Telescope k) -> Telescope (S k)\n\n ||| A tuple of values of each type in the telescope\n public export\n Environment : Right.Telescope k -> Type\n Environment [] = ()\n Environment (ty .- gamma) = (v : ty ** Environment (gamma v))\n\n export\n empty : (0 gamma : Right.Telescope Z) -> Environment gamma\n empty {gamma = []} = ()\n\n export\n snoc : (gamma : Right.Telescope k) -> (Environment gamma -> Type) -> Right.Telescope (S k)\n snoc [] tau = tau () .- const []\n snoc (sigma .- gamma) tau = sigma .- \\ v => snoc (gamma v) (\\ env => tau (v ** env))\n\n export\n unsnoc : {k : Nat} -> (gamma : Right.Telescope (S k)) ->\n (delta : Right.Telescope k\n ** sigma : (Environment delta -> Type)\n ** (env : Environment delta) -> sigma env -> Environment gamma)\n unsnoc {k = Z} (sigma .- gamma) = ([] ** const sigma ** \\ (), v => (v ** empty (gamma v)))\n unsnoc {k = S k} (sigma .- gamma)\n = (sigma .- delta ** uncurry tau ** \\ (v ** env) => transp v env) where\n\n delta : sigma -> Right.Telescope k\n delta v = fst (unsnoc (gamma v))\n\n tau : (v : sigma) -> Environment (delta v) -> Type\n tau v = fst (snd (unsnoc (gamma v)))\n\n transp : (v : sigma) -> (env : Environment (delta v)) -> tau v env -> Environment (sigma .- gamma)\n transp v env w = (v ** (snd (snd (unsnoc (gamma v))) env w))\n\n export\n (++) : (gamma : Right.Telescope m) -> (Environment gamma -> Right.Telescope n) -> Right.Telescope (m + n)\n [] ++ delta = delta ()\n (sigma .- gamma) ++ delta = sigma .- (\\ v => (gamma v ++ (\\ env => delta (v ** env))))\n\n export\n split : (gamma : Right.Telescope m) -> (delta : Environment gamma -> Right.Telescope n) ->\n Environment (gamma ++ delta) ->\n (env : Environment gamma ** Environment (delta env))\n split [] delta env = (() ** env)\n split (sigma .- gamma) delta (v ** env) =\n let (env1 ** env2) = split (gamma v) (\\env => delta (v ** env)) env in\n ((v ** env1) ** env2)\n\nnamespace Tree\n\n infixl 4 ++\n\n mutual\n ||| A tree of dependent types\n public export\n data Telescope : (k : Nat) -> Type where\n Nil : Telescope 0\n Elt : Type -> Telescope 1\n (++) : (gamma : Tree.Telescope m) ->\n (delta : Tree.Environment gamma -> Tree.Telescope n) ->\n Telescope (m + n)\n\n ||| A tuple of values of each type in the telescope\n public export\n Environment : Tree.Telescope k -> Type\n Environment [] = ()\n Environment (Elt t) = t\n Environment (gamma ++ delta) = (env : Environment gamma ** Environment (delta env))\n\n export\n concat : (gamma : Tree.Telescope k) -> (delta : Right.Telescope k ** Environment delta -> Environment gamma)\n concat Nil = ([] ** id)\n concat (Elt t) = ((t .- const []) ** fst)\n concat (gamma ++ delta) =\n let (thetaL ** transpL) = concat gamma in\n ((thetaL ++ \\ envL => fst (concat (delta (transpL envL))))\n ** \\ env =>\n let (env1 ** env2) = split thetaL (\\ envL => fst (concat (delta (transpL envL)))) env in\n (transpL env1 ** snd (concat (delta (transpL env1))) env2)\n )\n\ninfix 5 <++>\n\npublic export\n(<++>) : (gamma : Left.Telescope m) -> (Environment gamma -> Right.Telescope n) -> Right.Telescope (plusAcc m n)\n[] <++> delta = delta ()\n(gamma -. sigma ) <++> delta = gamma <++> (\\ env => sigma env .- \\ v => delta (env ** v))\n\ninfix 5 >++<\n\n(>++<) : {m, n : Nat} -> (gamma : Right.Telescope m) -> (Environment gamma -> Left.Telescope n) ->\n Left.Telescope (plusAcc m n)\n[] >++< delta = delta ()\ngamma@(_ .- _) >++< delta =\n let (gamma ** sigma ** transp) = unsnoc gamma in\n gamma >++< \\ env => (cons (sigma env) (\\ v => delta (transp env v)))\n\nexport\nleftToRight : Left.Telescope m -> Right.Telescope m\nleftToRight gamma = rewrite sym (plusAccZeroRightNeutral m) in (gamma <++> const [])\n\nexport\nrightToLeft : {m : Nat} -> Right.Telescope m -> Left.Telescope m\nrightToLeft gamma = rewrite sym (plusAccZeroRightNeutral m) in (gamma >++< const [])\n", "meta": {"hexsha": "a9ce378a3b5bfd1e65050028bd416be701836d65", "size": 7228, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/contrib/Data/Telescope/Telescope.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/Telescope.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/Telescope.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": 33.6186046512, "max_line_length": 112, "alphanum_fraction": 0.5842556724, "num_tokens": 2143, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321889812554, "lm_q2_score": 0.7025300636233416, "lm_q1q2_score": 0.5659808329820133}}
{"text": "module Interfaces.VerifiedOrd\n\nimport Data.Fin\n\n%default total\n%access public export\n\ntypeOf : (x : a) -> Type\ntypeOf {a} x = a\n\nreverseOrd : Ordering -> Ordering\nreverseOrd EQ = EQ\nreverseOrd LT = GT\nreverseOrd GT = LT\n\norderPair : Ordering -> Ordering -> Ordering\norderPair EQ x = x\norderPair x _ = x\n\ndata DecOrd : Ordering -> Type where\n IsEQ : (o = EQ) -> DecOrd o\n IsLT : (o = LT) -> DecOrd o\n IsGT : (o = GT) -> DecOrd o\n\ndecOrd : (o : Ordering) -> DecOrd o\ndecOrd EQ = IsEQ Refl\ndecOrd GT = IsGT Refl\ndecOrd LT = IsLT Refl\n\ndecOrdEq : (o : Ordering) -> Dec (o = EQ)\ndecOrdEq EQ = Yes Refl\ndecOrdEq LT = No (\\Refl impossible)\ndecOrdEq GT = No (\\Refl impossible)\n\ninterface VerifiedOrd a where\n order : a -> a -> Ordering\n ordRefl : (x : a) -> order x x = EQ\n reflOrd : (x : a) -> (y : a) -> order x y = EQ -> x = y\n ordSym : (x : a) -> (y : a) -> order x y = reverseOrd (order y x)\n ordTrans : (left : a) -> (middle : a) -> (right : a) -> order left middle = order middle right -> order left middle = order left right\n\nordRefl' : VerifiedOrd a => (x : a) -> (y : a) -> (x = y) -> order x y = EQ\nordRefl' x x Refl = ordRefl x\n\ndecEqVerifiedOrd : VerifiedOrd a => (x : a) -> (y : a) -> Dec (x = y)\ndecEqVerifiedOrd x y with (decOrdEq (order x y))\n | Yes p = Yes $ reflOrd x y p\n | No p = No $ \\xeqy => p $ ordRefl' x y xeqy\n\nimplementation VerifiedOrd () where\n order = compare\n ordRefl () = Refl\n reflOrd () () _ = Refl\n ordSym () () = Refl\n ordTrans () () () _ = Refl\n\nimplementation VerifiedOrd Bool where\n order = compare\n ordRefl True = Refl\n ordRefl False = Refl\n reflOrd True True _ = Refl\n reflOrd True False Refl impossible\n reflOrd False True Refl impossible\n reflOrd False False _ = Refl\n ordSym True True = Refl\n ordSym True False = Refl\n ordSym False True = Refl\n ordSym False False = Refl\n ordTrans False False False _ = Refl\n ordTrans True True True _ = Refl\n ordTrans False False True Refl impossible\n ordTrans False True False Refl impossible\n ordTrans True False False Refl impossible\n ordTrans False True True Refl impossible\n ordTrans True False True Refl impossible\n ordTrans True True False Refl impossible\n\npair_ordTrans_lemma1 : (VerifiedOrd a, VerifiedOrd b) =>\n {l1, m1, r1 : a} ->\n {l2, m2, r2 : b} ->\n (order l1 m1 = GT) ->\n (order m1 r1 = LT) ->\n (orderPair (order l1 m1) (order l2 m2) = orderPair (order m1 r1) (order m2 r2)) ->\n Void\npair_ordTrans_lemma1 p1 p2 = rewrite p1 in rewrite p2 in \\Refl impossible\n\npair_ordTrans_lemma2 : (VerifiedOrd a, VerifiedOrd b) =>\n {l1, m1, r1 : a} ->\n {l2, m2, r2 : b} ->\n (order l1 m1 = LT) ->\n (order m1 r1 = GT) ->\n (orderPair (order l1 m1) (order l2 m2) = orderPair (order m1 r1) (order m2 r2)) ->\n Void\npair_ordTrans_lemma2 p1 p2 = rewrite p1 in rewrite p2 in \\Refl impossible\n\npair_ordTrans_lemma3 : (VerifiedOrd a, VerifiedOrd b) =>\n (l1 : a) ->\n (m1 : a) ->\n (r1 : a) ->\n (l2 : b) ->\n (m2 : b) ->\n (r2 : b) ->\n (order l1 m1 = EQ) ->\n (order m1 r1 = EQ) ->\n (orderPair (order l1 m1) (order l2 m2) = orderPair (order m1 r1) (order m2 r2)) ->\n (order l2 m2 = order m2 r2)\npair_ordTrans_lemma3 _ _ _ _ _ _ p1 p2 = rewrite p1 in rewrite p2 in \\x => x\n\npair_ordTrans_lemma4 : (VerifiedOrd a, VerifiedOrd b) =>\n (l1 : a) ->\n (m1 : a) ->\n (r1 : a) ->\n (l2 : b) ->\n (m2 : b) ->\n (r2 : b) ->\n (order l1 m1 = EQ) ->\n (order m1 r1 = LT) ->\n (orderPair (order l1 m1) (order l2 m2) = orderPair (order m1 r1) (order m2 r2)) ->\n (order l2 m2 = LT)\npair_ordTrans_lemma4 _ _ _ _ _ _ p1 p2 = rewrite p1 in rewrite p2 in \\x => x\n\npair_ordTrans_lemma5 : (VerifiedOrd a, VerifiedOrd b) =>\n (l1 : a) ->\n (m1 : a) ->\n (r1 : a) ->\n (l2 : b) ->\n (m2 : b) ->\n (r2 : b) ->\n (order l1 m1 = EQ) ->\n (order m1 r1 = GT) ->\n (orderPair (order l1 m1) (order l2 m2) = orderPair (order m1 r1) (order m2 r2)) ->\n (order l2 m2 = GT)\npair_ordTrans_lemma5 _ _ _ _ _ _ p1 p2 = rewrite p1 in rewrite p2 in \\x => x\n\nimplementation (VerifiedOrd a, VerifiedOrd b) => VerifiedOrd (a, b) where\n order (x1, x2) (y1, y2) = orderPair (order x1 y1) (order x2 y2)\n ordRefl (x1, x2) = rewrite ordRefl x1 in ordRefl x2\n reflOrd (x1, x2) (y1, y2) p with (decOrdEq (order x1 y1))\n | Yes p2 with (reflOrd x1 y1 p2)\n reflOrd (x1, x2) (x1, y2) p | Yes p2 | Refl with (order x1 x1)\n | EQ = rewrite reflOrd x2 y2 p in Refl\n reflOrd (_, _) (_, _) Refl | Yes _ | Refl | LT impossible\n reflOrd (_, _) (_, _) Refl | Yes _ | Refl | GT impossible\n | No p2 with (order x1 y1)\n reflOrd (_, _) (_, _) Refl | No _ | GT impossible\n reflOrd (_, _) (_, _) Refl | No _ | LT impossible\n | EQ = void $ p2 Refl\n ordSym (x1, x2) (y1, y2) with (decOrd (order y1 x1))\n | IsEQ p = rewrite ordSym x1 y1 in rewrite p in ordSym x2 y2\n | IsLT p = rewrite ordSym x1 y1 in rewrite p in Refl\n | IsGT p = rewrite ordSym x1 y1 in rewrite p in Refl\n ordTrans (l1, l2) (m1, m2) (r1, r2) p with (decOrd (order l1 m1))\n | IsLT p1 with (decOrd (order m1 r1))\n | IsLT p2 = rewrite sym (ordTrans l1 m1 r1 (trans p1 (sym p2))) in rewrite p1 in Refl\n | IsGT p2 = void $ pair_ordTrans_lemma2 {l1=l1} {l2=l2} {m1=m1} {m2=m2} {r1=r1} {r2=r2} p1 p2 p\n | IsEQ p2 with (reflOrd m1 r1 p2)\n ordTrans (l1, l2) (m1, m2) (m1, r2) p | IsLT p1 | IsEQ _ | Refl with (order l1 m1)\n ordTrans (_, _) (_, _) (_, _) _ | IsLT Refl | IsEQ _ | Refl | EQ impossible\n | LT = Refl\n | GT = Refl\n | IsGT p1 with (decOrd (order m1 r1))\n | IsGT p2 = rewrite sym (ordTrans l1 m1 r1 (trans p1 (sym p2))) in rewrite p1 in Refl\n | IsLT p2 = void $ pair_ordTrans_lemma1 {l1=l1} {l2=l2} {m1=m1} {m2=m2} {r1=r1} {r2=r2} p1 p2 p\n | IsEQ p2 with (reflOrd m1 r1 p2)\n ordTrans (l1, l2) (m1, m2) (m1, r2) p | IsGT p1 | IsEQ _ | Refl with (order l1 m1)\n ordTrans (_, _) (_, _) (_, _) _ | IsGT Refl | IsEQ _ | Refl | EQ impossible\n | LT = Refl\n | GT = Refl\n | IsEQ p1 with (decOrd (order m1 r1))\n | IsEQ p2 = rewrite p1 in rewrite sym (ordTrans l1 m1 r1 (trans p1 (sym p2))) in rewrite p1 in ordTrans l2 m2 r2 (pair_ordTrans_lemma3 l1 m1 r1 l2 m2 r2 p1 p2 p)\n | IsLT p2 = rewrite p1 in rewrite reflOrd l1 m1 p1 in rewrite p2 in pair_ordTrans_lemma4 l1 m1 r1 l2 m2 r2 p1 p2 p\n | IsGT p2 = rewrite p1 in rewrite reflOrd l1 m1 p1 in rewrite p2 in pair_ordTrans_lemma5 l1 m1 r1 l2 m2 r2 p1 p2 p\n\nimplementation VerifiedOrd a => VerifiedOrd (List a) where\n order [] [] = EQ\n order [] (_::_) = LT\n order (_::_) [] = GT\n order (x::xs) (y::ys) = orderPair (order x y) (order xs ys)\n ordRefl [] = Refl\n ordRefl (x::xs) = rewrite ordRefl x in ordRefl xs\n reflOrd [] [] _ = Refl\n reflOrd (x::xs) (y::ys) p with (decOrdEq (order x y))\n | Yes p2 with (reflOrd x y p2)\n reflOrd (x::xs) (x::ys) p | Yes p2 | Refl with (order x x)\n reflOrd (x::xs) (x::ys) p | Yes p2 | Refl | EQ = rewrite reflOrd xs ys p in Refl\n reflOrd (_::_) (_::_) _ | Yes Refl | Refl | LT impossible\n reflOrd (_::_) (_::_) _ | Yes Refl | Refl | GT impossible\n | No p2 with (order x y)\n | EQ = void $ p2 Refl\n | LT = void $ p2 p\n | GT = void $ p2 p\n reflOrd [] (_::_) Refl impossible\n reflOrd (_::_) [] Refl impossible\n ordSym [] [] = Refl\n ordSym [] (_::_) = Refl\n ordSym (_::_) [] = Refl\n ordSym (x::xs) (y::ys) with (decOrd (order x y))\n | IsLT p = rewrite ordSym y x in rewrite p in Refl\n | IsGT p = rewrite ordSym y x in rewrite p in Refl\n | IsEQ p = rewrite ordSym y x in rewrite p in ordSym xs ys\n ordTrans [] [] zs p = p\n ordTrans [] (y::ys) (z::zs) p = Refl\n ordTrans (x::xs) (y::ys) [] p = p\n ordTrans (x::xs) (y::ys) (z::zs) p with (decOrd (order x y))\n | IsLT p1 with (decOrd (order y z))\n | IsLT p2 = rewrite sym (ordTrans x y z (trans p1 (sym p2))) in rewrite p1 in Refl\n | IsGT p2 = void $ (the (typeOf p -> Void) (rewrite p1 in rewrite p2 in \\Refl impossible)) p\n | IsEQ p2 = rewrite (sym (reflOrd y z p2)) in rewrite p1 in Refl\n | IsGT p1 with (decOrd (order y z))\n | IsGT p2 = rewrite sym (ordTrans x y z (trans p1 (sym p2))) in rewrite p1 in Refl\n | IsLT p2 = void $ (the (typeOf p -> Void) (rewrite p1 in rewrite p2 in \\Refl impossible)) p\n | IsEQ p2 = rewrite (sym (reflOrd y z p2)) in rewrite p1 in Refl\n | IsEQ p1 with (decOrd (order y z))\n | IsEQ p2 = the (typeOf p -> order (x::xs) (y::ys) = order (x::xs) (z::zs)) (rewrite sym (reflOrd y z p2) in rewrite reflOrd x y p1 in rewrite ordRefl y in ordTrans xs ys zs) p\n | IsGT p2 = rewrite p1 in rewrite (reflOrd x y p1) in rewrite p2 in (the (typeOf p -> order xs ys = GT) (rewrite p1 in rewrite p2 in id)) p\n | IsLT p2 = rewrite p1 in rewrite (reflOrd x y p1) in rewrite p2 in (the (typeOf p -> order xs ys = LT) (rewrite p1 in rewrite p2 in id)) p\n ordTrans [] (_::_) [] Refl impossible\n ordTrans (_::_) [] [] Refl impossible\n ordTrans (_::_) [] (_::_) Refl impossible\n\nimplementation VerifiedOrd Nat where\n order = compare\n ordRefl Z = Refl\n ordRefl (S n) = ordRefl n\n reflOrd Z Z _ = Refl\n reflOrd Z (S _) Refl impossible\n reflOrd (S _) Z Refl impossible\n reflOrd (S n) (S m) p = cong (reflOrd n m p)\n ordSym Z Z = Refl\n ordSym Z (S _) = Refl\n ordSym (S _) Z = Refl\n ordSym (S m) (S n) = ordSym m n\n ordTrans Z Z Z _ = Refl\n ordTrans Z (S m) (S r) _ = Refl\n ordTrans (S l) (S m) Z p = p\n ordTrans (S l) (S m) (S r) p = ordTrans l m r p\n ordTrans Z Z (S r) Refl impossible\n ordTrans Z (S m) Z Refl impossible\n ordTrans (S l) Z Z Refl impossible\n ordTrans (S l) Z (S r) Refl impossible\n\nimplementation VerifiedOrd (Fin n) where\n order = compare\n ordRefl FZ = Refl\n ordRefl (FS n) = ordRefl n\n reflOrd FZ FZ _ = Refl\n reflOrd (FS n) (FS m) p = cong $ reflOrd n m p\n reflOrd FZ (FS _) Refl impossible\n reflOrd (FS _) FZ Refl impossible\n ordSym FZ FZ = Refl\n ordSym FZ (FS _) = Refl\n ordSym (FS _) FZ = Refl\n ordSym (FS m) (FS n) = ordSym m n\n ordTrans FZ FZ FZ _ = Refl\n ordTrans FZ (FS m) (FS r) _ = Refl\n ordTrans (FS l) (FS m) FZ p = p\n ordTrans (FS l) (FS m) (FS r) p = ordTrans l m r p\n ordTrans FZ FZ (FS r) Refl impossible\n ordTrans FZ (FS m) FZ Refl impossible\n ordTrans (FS l) FZ FZ Refl impossible\n ordTrans (FS l) FZ (FS r) Refl impossible\n", "meta": {"hexsha": "cc820191f42a5a9b1d7ec48bd2632175b4a7ee8a", "size": 11164, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Interfaces/VerifiedOrd.idr", "max_stars_repo_name": "mat8913/l2idris", "max_stars_repo_head_hexsha": "d193e85daf5a38ec86459b814f38b4269c10f61c", "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": "Interfaces/VerifiedOrd.idr", "max_issues_repo_name": "mat8913/l2idris", "max_issues_repo_head_hexsha": "d193e85daf5a38ec86459b814f38b4269c10f61c", "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": "Interfaces/VerifiedOrd.idr", "max_forks_repo_name": "mat8913/l2idris", "max_forks_repo_head_hexsha": "d193e85daf5a38ec86459b814f38b4269c10f61c", "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": 42.6106870229, "max_line_length": 182, "alphanum_fraction": 0.558760301, "num_tokens": 3961, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673269042767, "lm_q2_score": 0.6959583187272711, "lm_q1q2_score": 0.5657217781806314}}
{"text": "import Data.Either\nimport Data.List\nimport Data.Maybe\nimport Data.String\n\nimport System.File\n\ndata LowPoint = L Nat | N Nat\n\nget : LowPoint -> Nat\nget (L k) = k\nget (N k) = k\n\nparseLines : (String -> Maybe a) -> String -> List a\nparseLines f s = catMaybes $ f <$> lines s\n\nlowPointsRow : Nat -> List Nat -> List LowPoint\nlowPointsRow n [] = []\nlowPointsRow n (x :: []) = if x < n then [L x] else [N x]\nlowPointsRow n (x :: (y :: xs)) = (if x < n && x < y then L x else N x) :: lowPointsRow x (y :: xs)\n\ncomp : Nat -> LowPoint -> LowPoint\ncomp p (L k) = if k < p then L k else N k\ncomp _ (N k) = N k\n\ncomp3 : Nat -> LowPoint -> Nat -> LowPoint\ncomp3 p (L k) n = if k < n && k < p then L k else N k\ncomp3 _ (N k) _ = N k\n\nlowPointsCol : List Nat -> List (List LowPoint) -> List (List LowPoint)\nlowPointsCol prev [] = []\nlowPointsCol prev (row :: []) = [ (\\(p, r) => comp p r) <$> zip prev row ]\nlowPointsCol prev (row :: (next :: rows)) = ((\\(p, r, n) => comp3 p r (get n)) <$> zip3 prev row next) :: lowPointsCol (get <$> row) (next :: rows)\n\nHMap : Type\nHMap = List ((Nat, Nat), Nat)\n\ntoMap : (Nat, Nat) -> List (List LowPoint) -> (HMap, List (Nat, Nat))\ntoMap (x, y) [] = ([], [])\ntoMap (x, y) ([] :: xs) = toMap (0, y + 1) xs\ntoMap (x, y) (((L k) :: ys) :: xs) = let (m, ls) = toMap (x + 1, y) (ys :: xs) in\n (((x, y), k) :: m, (x,y) :: ls)\ntoMap (x, y) (((N k) :: ys) :: xs) = let (m, ls) = toMap (x + 1, y) (ys :: xs) in\n (((x, y), k) :: m, ls)\n\nbasinFrom : HMap -> List (Nat, Nat) -> (Nat, Nat) -> List (Nat, Nat)\nbasinFrom m p (x, y) = if elem (x, y) p\n then p\n else case lookup (x, y) m of\n Just k => if k < 9\n then let p0 = (x, y) :: p\n p1 = basinFrom m p0 (x + 1, y)\n p2 = basinFrom m p1 (x, y + 1)\n p3 = basinFrom m p2 (minus x 1, y) in\n basinFrom m p3 (x, minus y 1)\n else p\n Nothing => p\n\nrun : String -> IO ()\nrun s = do let l = (\\l => catMaybes $ parsePositive {a=Nat} . singleton <$> unpack l) <$> lines s\n let r = lowPointsCol (replicate 100 10) $ lowPointsRow 10 <$> l\n let (m, ls) = toMap (0,0) r\n let c = product $ take 3 $ reverse $ sort $ (length . basinFrom m []) <$> ls\n putStrLn $ show c\n\nmain : IO ()\nmain = do Right s <- readFile \"input.txt\"\n | Left err => putStrLn $ show err\n run s\n\n", "meta": {"hexsha": "ee7b996bd94b4527bfece41174ac9946a2dcf9c4", "size": 2791, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "09/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": "09/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": "09/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": 39.3098591549, "max_line_length": 147, "alphanum_fraction": 0.4421354353, "num_tokens": 848, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.882427872638409, "lm_q2_score": 0.6406358479787609, "lm_q1q2_score": 0.5653149284678013}}
{"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 Data.DVect\n\nimport Data.Vect\n\n%access export\n\nusing (aTy : Type, elemTy : (aTy -> Type), x : aTy)\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.\n public export\n data DVect : (aTy : Type)\n -> (len : Nat)\n -> (elemTy : aTy -> Type)\n -> (as : Vect len aTy)\n -> Type where\n ||| Create an empty List\n Nil : DVect aTy Z elemTy Nil\n ||| Cons\n |||\n ||| @elem The element to add\n ||| @rest The list for `elem` to be added to.\n (::) : (elem : elemTy x)\n -> (rest : DVect aTy n elemTy xs)\n -> DVect aTy (S n) elemTy (x::xs)\n\n-- -------------------------------------------------------------- [ Form Tests ]\nisNil : DVect aTy n eTy as -> Bool\nisNil Nil = True\nisNil (x::xs) = False\n\nisCons : DVect aTy n eTy as -> Bool\nisCons l = isNil l == False\n\n-- ------------------------------------------------------------------ [ Length ]\n\nlength : DVect aTy n eTy as -> Nat\nlength {n} _ = n\n\n-- ---------------------------------------------------------------- [ Indexing ]\n\n{- TODO Safely Index the List\n\nindex : (n : Nat)\n -> (l : DVect aTy eTy as)\n -> (ok : lt n (length l) = True)\n -> (a : aTy ** eTy a)\nindex Z (x::xs) p = (_ ** x)\nindex (S n) (x::xs) p = index n xs ...\nindex _ Nil Refl impossible\n-}\n\nindex : (n : Nat)\n -> (l : DVect aTy l eTy as)\n -> Maybe $ DPair aTy eTy\nindex Z (x::xs) = Just (_ ** x)\nindex (S n) (x::xs) = index n xs\nindex _ Nil = Nothing\n\nhead : (l : DVect aTy n eTy as) -> {auto ok : isCons l = True} -> DPair aTy eTy\nhead Nil {ok=Refl} impossible\nhead (x::xs) {ok=p} = (_ ** x)\n\ntail : (l : DVect aTy (S n) eTy (a :: as))\n -> {auto ok : isCons l = True}\n -> (DVect aTy n eTy as)\ntail Nil {ok=Refl} impossible\ntail (x::xs) {ok=p} = xs\n\n\nlast : (l : DVect aTy n eTy as) -> {auto ok : isCons l = True} -> DPair aTy eTy\nlast Nil {ok=Refl} impossible\nlast [x] {ok=p} = (_ ** x)\nlast (x::y::ys) {ok=p} = last (y::ys) {ok=Refl}\n\n-- TODO init\n\n-- --------------------------------------------------------- [ Bob The Builder ]\n\n(++) : DVect aTy x eTy xs\n -> DVect aTy y eTy ys\n -> DVect aTy (x+y) eTy (xs ++ ys)\n(++) Nil ys = ys\n(++) (x::xs) ys = x :: (xs ++ ys)\n\n-- TODO replicate\n\n-- ---------------------------------------------------------------- [ SubLists ]\n-- TODO\n\n-- ----------------------------------------------------------------- [ Functor ]\n-- TODO\n{-\nmapSV : (eXTy x -> eYTy y)\n -> (DVect xTy l eXTy xs)\n -> (ys : Vect l yTy ** DVect yTy l eYTy ys)\nmapSV f Nil = (Nil ** Nil)\nmapSV f (x::xs) = let (ys ** xs') = mapSV f xs in (y :: ys ** f x ** xs')\n-}\n-- ---------------------------------------------------------------- [ Equality ]\n-- TODO\n\n-- ------------------------------------------------------------------- [ Order ]\n\n-- TODO\n\n-- ----------------------------------------------------------------- [ Folding ]\n-- TODO\n\n-- -------------------------------------------------------- [ Membership Tests ]\n-- TODO\n\n-- --------------------------------------------------------------- [ Searching ]\n-- TODO\n\n-- ----------------------------------------------------------------- [ Filters ]\n-- TODO\n\n-- ------------------------------------------------------------ [ Partitioning ]\n-- TODO\n\n-- -------------------------------------------------------------------- [ Show ]\n-- TODO\n\n-- ------------------------------------------- [ Applicative/Monad/Traversable ]\n-- TODO\n\n-- -------------------------------------------------------- [ Decidable Equals ]\n-- TODO\n\n-- --------------------------------------------------------------------- [ EOF ]\n", "meta": {"hexsha": "0fb074d2fad7e8272b3ae95c387fa80c6ccd8f3c", "size": 4529, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Data/DVect.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/DVect.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/DVect.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": 30.8095238095, "max_line_length": 80, "alphanum_fraction": 0.3978803268, "num_tokens": 1159, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.7401743620390163, "lm_q1q2_score": 0.5651111076159455}}
{"text": "module Example.DecEq'\n\npublic export\ndata Dec' : Type -> Type where\n Yes : (a : x) -> Dec' x\n No : Dec' x\n\npublic export\ninterface DecEq' t where\n decEq' : (x1 : t) -> (x2 : t) -> Dec' (x1 = x2)\n", "meta": {"hexsha": "1d1cfd00733e017b2a745a4c57420ed994d91dfc", "size": 198, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "2020.11.24-to-complex-data-gen-presentation/src/Example/DecEq'.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/DecEq'.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/DecEq'.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": 18.0, "max_line_length": 49, "alphanum_fraction": 0.5808080808, "num_tokens": 75, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8577681122619883, "lm_q2_score": 0.6584175072643415, "lm_q1q2_score": 0.5647695422863782}}
{"text": "module Dec3\n\nimport Data.Vect\n\n%default total\n\ndata Orientation = Up | Left | Down | Right\n\ndata MoverState : (position : (Int, Int)) -> (orientation : Orientation) -> Type where\n MkMoverState : (history : Vect n (Int, Int)) -> (values : Vect n Int) ->\n MoverState position orientation\n\nsumOfNeighbours : (history : Vect n (Int, Int)) -> (values : Vect n Int) -> (x, y : Int) -> Int\nsumOfNeighbours history values x y = foldl f 0 $ zip history values\n where\n f : Int -> ((Int, Int), Int) -> Int\n f agg (h, v) = case (abs (x - fst h), abs (y - snd h)) of\n (0, 1) => v + agg\n (1, 0) => v + agg\n (1, 1) => v + agg\n _ => agg\n\nmove : MoverState (x, y) orientation ->\n Either (MoverState (x, y) orientation)\n (Either (MoverState (x, y+1) Up)\n (Either (MoverState (x-1, y) Left)\n (Either (MoverState (x, y-1) Down)\n (MoverState (x+1, y) Right))))\nmove {x} {y} {orientation} (MkMoverState history values) =\n case orientation of\n -- (x, y), Up, left-turn possible => (x-1, y), Left\n -- (x, y), Up, left-turn impossible, up possible => (x, y+1), Up\n -- (x, y), Up, left-turn impossible, up impossible => (x, y), Up\n Up => case elem (x-1, y) history of\n False => Right (Right (Left (MkMoverState ((x, y) :: history) ((sumOfNeighbours history values x y) :: values))))\n True => case elem (x, y+1) history of\n False => Right (Left (MkMoverState ((x, y) :: history) ((sumOfNeighbours history values x y) :: values)))\n True => Left (MkMoverState history values)\n -- (x, y), Left, left-turn possible => (x, y-1), Downs\n -- (x, y), Left, left-turn impossible, left possible => (x-1, y), Left\n -- (x, y), Left, left-turn impossible, left impossible => (x, y), Left\n Left => case elem (x, y-1) history of\n False => Right (Right (Right (Left (MkMoverState ((x, y) :: history) ((sumOfNeighbours history values x y) :: values)))))\n True => case elem (x-1, y) history of\n False => Right (Right (Left (MkMoverState ((x, y) :: history) ((sumOfNeighbours history values x y) :: values))))\n True => Left (MkMoverState history values)\n -- (x, y), Down, left-turn possible => (x+1, y), Right\n -- (x, y), Down, left-turn impossible, down possible => (x, y-1), Down\n -- (x, y), Down, left-turn impossible, down impossible => (x, y), Down\n Down => case elem (x+1, y) history of\n False => Right (Right (Right (Right (MkMoverState ((x, y) :: history) ((sumOfNeighbours history values x y) :: values)))))\n True => case elem (x, y-1) history of\n False => Right (Right (Right (Left (MkMoverState ((x, y) :: history) ((sumOfNeighbours history values x y) :: values)))))\n True => Left (MkMoverState history values)\n -- (x, y), Right, left-turn possible => (x, y+1), Up\n -- (x, y), Right, left-turn impossible, right possible => (x+1, y), Right\n -- (x, y), Right, left-turn impossible, right impossible => (x, y), Right\n Right => case elem (x, y+1) history of\n False => Right (Left (MkMoverState ((x, y) :: history) ((sumOfNeighbours history values x y) :: values)))\n True => case elem (x+1, y) history of\n False => Right (Right (Right (Right (MkMoverState ((x, y) :: history) ((sumOfNeighbours history values x y) :: values)))))\n True => Left (MkMoverState history values)\n\nmanhattanDistance : (Int, Int) -> (Int, Int) -> Int\nmanhattanDistance (x1, y1) (x2, y2) = abs (x1 - x2) + abs (y1 - y2)\n\nwalkDistance : (steps: Nat) -> MoverState (x, y) orientation -> Int\nwalkDistance Z (MkMoverState [] []) = 0\nwalkDistance Z (MkMoverState (h :: hs) (v :: vs)) = manhattanDistance h $ last (h :: hs)\nwalkDistance (S k) state = case move state of\n Left state => walkDistance k state -- walkDistance state Z doesn't preserve totality for some reason\n Right (Left (state)) => walkDistance k state\n Right (Right (Left (state))) => walkDistance k state\n Right (Right (Right (Left (state)))) => walkDistance k state\n Right (Right (Right (Right (state)))) => walkDistance k state\n\ndec3a : Int\ndec3a = walkDistance {x = 0} {y = 0} {orientation = Down} 361527 (MkMoverState [] [])\n\ndata Fuel = Dry | More (Lazy Fuel)\n\npartial\nforever : Fuel\nforever = More forever\n\nwalkUntil : Fuel -> (p : Int -> Bool) -> MoverState (x, y) orientation -> Maybe Int\nwalkUntil Dry p state = Nothing\nwalkUntil (More fuel) p state = case move state of\n Left state' => recurse state'\n Right (Left (state')) => recurse state'\n Right (Right (Left (state'))) => recurse state'\n Right (Right (Right (Left (state')))) => recurse state'\n Right (Right (Right (Right (state')))) => recurse state'\n where\n recurse : (MoverState (x', y') orientation') -> Maybe Int\n recurse state = case state of\n MkMoverState _ [] => walkUntil fuel p state\n MkMoverState _ (v :: vs) => if p v then walkUntil fuel p state else Just v\n\ndec3b : Fuel -> Maybe Int\ndec3b fuel = walkUntil {x = 1} {y = 0} {orientation = Right} fuel (\\i => i <= 361527) (MkMoverState [(0, 0)] [1])\n", "meta": {"hexsha": "b6fcba1dc00c99747a966e45a4b52c29e5de9ecc", "size": 5109, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Dec3.idr", "max_stars_repo_name": "tscholak/AoC2017", "max_stars_repo_head_hexsha": "983eda0e6260e9cb22577e5f055ba1442f1e36ee", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-12-04T13:14:53.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-04T13:14:53.000Z", "max_issues_repo_path": "Dec3.idr", "max_issues_repo_name": "tscholak/AoC2017", "max_issues_repo_head_hexsha": "983eda0e6260e9cb22577e5f055ba1442f1e36ee", "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": "Dec3.idr", "max_forks_repo_name": "tscholak/AoC2017", "max_forks_repo_head_hexsha": "983eda0e6260e9cb22577e5f055ba1442f1e36ee", "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": 50.0882352941, "max_line_length": 130, "alphanum_fraction": 0.5995302408, "num_tokens": 1584, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8577681049901037, "lm_q2_score": 0.658417487156366, "lm_q1q2_score": 0.564769520250462}}
{"text": "-- exercises in \"Type-Driven Development with Idris\"\n-- chapter 14, section 2, Security part\n\n-- check that all functions are total\n%default total\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 PutStr : String -> ShellCmd () state (const state)\n Pure : (res : ty) -> ShellCmd ty (state res) state\n (>>=) : ShellCmd a state1 state2 ->\n ((res : a) -> ShellCmd b (state2 res) state3) ->\n ShellCmd b state1 state3\n\nsession : ShellCmd () LoggedOut (const LoggedOut)\nsession = do Correct <- Password \"wurzel\"\n | Incorrect => PutStr \"Wrong password\"\n msg <- GetSecret\n PutStr (\"Secret code: \" ++ show msg ++ \"\\n\")\n Logout\n\n-- sessionBad : ShellCmd () LoggedOut (const LoggedOut)\n-- sessionBad = do Password \"wurzel\"\n-- msg <- GetSecret\n-- PutStr (\"Secret code: \" ++ show msg ++ \"\\n\")\n-- Logout\n\n-- noLogout : ShellCmd () LoggedOut (const LoggedOut)\n-- noLogout = do Correct <- Password \"wurzel\"\n-- | Incorrect => PutStr \"Wrong password\"\n-- msg <- GetSecret\n-- PutStr (\"Secret code: \" ++ show msg ++ \"\\n\")\n", "meta": {"hexsha": "c3ceb8d0f6c71432e5b8f6e6f7dc74ca2a513a3c", "size": 1621, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "chapter14/Security.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/Security.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/Security.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": 39.5365853659, "max_line_length": 75, "alphanum_fraction": 0.548426897, "num_tokens": 381, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031738057795402, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.5642537398726258}}
{"text": "module WithProof\n\n%default total\n\nfilter : (p : a -> Bool) -> (xs : List a) -> List a\nfilter p [] = []\nfilter p (x :: xs) with (p x)\n filter p (x :: xs) | False = filter p xs\n filter p (x :: xs) | True = x :: filter p xs\n\n\nfilterSquared : (p : a -> Bool) -> (xs : List a) ->\n filter p (filter p xs) === filter p xs\nfilterSquared p [] = Refl\n{-\nfilterSquared p (x :: xs) with (p x)\n filterSquared p (x :: xs) | False = filterSquared p xs -- easy\n filterSquared p (x :: xs) | True = ?a\n -- argh! stuck on another with-block casing on (p x)!\n -- we could check (p x) again but how do we prove it\n -- can only ever be `True`?!\n-}\nfilterSquared p (x :: xs) with (p x) proof eq\n filterSquared p (x :: xs) | False = filterSquared p xs -- easy\n filterSquared p (x :: xs) | True\n = rewrite eq in cong (x ::) (filterSquared p xs)\n", "meta": {"hexsha": "76570fa731bcd1738b6a6c9cf502b6da79d69fd3", "size": 856, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "tests/idris2/with005/WithProof.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/with005/WithProof.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/with005/WithProof.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": 31.7037037037, "max_line_length": 64, "alphanum_fraction": 0.5759345794, "num_tokens": 274, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677583778258, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.5642466942750625}}
{"text": "module MonadicMemo\n\n-- Monadic memoization, based on http://www.cs.utexas.edu/~wcook/Drafts/2006/MemoMixins.pdf\n\nimport Control.Monad.Identity\nimport Control.Monad.State\nimport Data.SortedMap\n\nGen : Type -> Type\nGen a = a -> a\n\ngmFib : Monad m => Gen (Int -> m Int)\ngmFib f 0 = pure 0\ngmFib f 1 = pure 1\ngmFib f n = do nm1 <- f (n - 1)\n nm2 <- f (n - 2)\n pure (nm1 + nm2)\n\n\nfix : ((a -> b) -> (a -> b)) -> a -> b\nfix f x = f (fix f) x\n\ntestIden : Int -> Int\ntestIden = runIdentity . (fix gmFib)\n\nmemo : MonadState (SortedMap a b) (StateT (SortedMap a b) m) => Gen (a -> StateT (SortedMap a b) m b)\nmemo f x = do map <- get\n apply map f x\n where\n apply : MonadState (SortedMap a b) (StateT (SortedMap a b) m) => SortedMap a b -> Gen (a -> StateT (SortedMap a b) m b)\n apply map f x with (lookup x map)\n apply map f x | Nothing = do y <- f x\n put (insert x y map)\n pure y\n apply map f x | (Just y) = pure y\n\n\ntestMemo : Int -> Int\ntestMemo x = fst . runIdentity $ runStateT (getState x) empty\n where\n getState : Int -> StateT (SortedMap Int Int) Identity Int\n getState x = fix (memo . gmFib) x\n", "meta": {"hexsha": "6a220160600342438f8a1b945136fce604ac8841", "size": 1229, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/MonadicMemo.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/MonadicMemo.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/MonadicMemo.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": 28.5813953488, "max_line_length": 123, "alphanum_fraction": 0.5679414158, "num_tokens": 394, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956580903722561, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.5641368051326973}}
{"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\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 = TRec _ e10 e11} (StRec x) (StRec y) = \n cong {f = \\e => TRec e e10 e11} $ stepDeterministic x y\n--\nstepDeterministic (StRec x) (StRecSucc y) = absurd $ valueIrreducible _ y x\n--\nstepDeterministic StRecZero StRecZero = Refl\n--\nstepDeterministic (StRecSucc x) (StRec y) = absurd $ valueIrreducible _ x y\n--\nstepDeterministic (StRecSucc x) (StRecSucc y) = Refl\n--\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 (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 (BStRecZero y z) (BStValue _) impossible\n--\nbigStepDeterministic (BStRecZero y z) (BStRecZero w s) = bigStepDeterministic z s\n--\nbigStepDeterministic (BStRecZero y z) (BStRecSucc x w) = \n let ih = bigStepDeterministic y x\n in absurd $ zeroNotSucc ih\n--\nbigStepDeterministic (BStRecSucc x y) (BStValue _) impossible\n--\nbigStepDeterministic (BStRecSucc x y) (BStRecZero w s) =\n let ih = bigStepDeterministic x w\n in absurd $ zeroNotSucc $ sym ih\n--\nbigStepDeterministic {e1 = TRec e e10 e11} {e2 = e2} (BStRecSucc x y) (BStRecSucc z w) = \n let ih = injectiveSucc $ bigStepDeterministic x z\n y' = replace {P = \\x => BigStep (subst x FZ (subst (TRec x e10 e11) FZ e11)) e2} ih y\n in bigStepDeterministic y' w\n--\nbigStepDeterministic (BStValue _) (BStValue _) = Refl\n--\nbigStepDeterministic (BStValue _) (BStApp z w t) 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) FZ (fst x)) e2} peq u\n in bigStepDeterministic u' v\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) = 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", "meta": {"hexsha": "2b2df8e36d0347d005d63527f08d5ad4bfc74372", "size": 7223, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "total/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": "total/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": "total/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": 32.536036036, "max_line_length": 95, "alphanum_fraction": 0.6999861553, "num_tokens": 2571, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8705972549785203, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.5639713384897115}}
{"text": "module Data.Maybe\n\npublic export\nisNothing : Maybe a -> Bool\nisNothing Nothing = True\nisNothing (Just _) = False\n\npublic export\nisJust : Maybe a -> Bool\nisJust Nothing = False\nisJust (Just _) = True\n\n||| Proof that some `Maybe` is actually `Just`\npublic export\ndata IsJust : Maybe a -> Type where\n ItIsJust : IsJust (Just x)\n\nexport\nUninhabited (IsJust Nothing) where\n uninhabited ItIsJust impossible\n\n||| Decide whether a 'Maybe' is 'Just'\npublic export\nisItJust : (v : Maybe a) -> Dec (IsJust v)\nisItJust (Just _) = Yes ItIsJust\nisItJust Nothing = No absurd\n\n||| Convert a `Maybe a` value to an `a` value by providing a default `a` value\n||| in the case that the `Maybe` value is `Nothing`.\npublic export\nfromMaybe : (Lazy a) -> Maybe a -> a\nfromMaybe def Nothing = def\nfromMaybe _ (Just j) = j\n\n||| Returns the `a` value of a `Maybe a` which is proved `Just`.\npublic export\nfromJust : (v : Maybe a) -> IsJust v => a\nfromJust (Just x) = x\nfromJust Nothing impossible\n\n||| Returns `Just` the given value if the conditional is `True`\n||| and `Nothing` if the conditional is `False`.\npublic export\ntoMaybe : Bool -> Lazy a -> Maybe a\ntoMaybe True j = Just j\ntoMaybe False _ = Nothing\n\nexport\njustInjective : Just x = Just y -> x = y\njustInjective Refl = Refl\n\n||| Convert a `Maybe a` value to an `a` value, using `neutral` in the case\n||| that the `Maybe` value is `Nothing`.\npublic export\nlowerMaybe : Monoid a => Maybe a -> a\nlowerMaybe Nothing = neutral\nlowerMaybe (Just x) = x\n\n||| Returns `Nothing` when applied to `neutral`, and `Just` the value otherwise.\nexport\nraiseToMaybe : (Monoid a, Eq a) => a -> Maybe a\nraiseToMaybe x = if x == neutral then Nothing else Just x\n", "meta": {"hexsha": "437def893a281b8bb2670acd3abe6f24ff92e3a6", "size": 1683, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/base/Data/Maybe.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/Maybe.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/Maybe.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": 26.7142857143, "max_line_length": 80, "alphanum_fraction": 0.696969697, "num_tokens": 499, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396211, "lm_q2_score": 0.7057850340255385, "lm_q1q2_score": 0.5633482820856934}}
{"text": "module Commons.Data.Rig\n\nimport public Data.Vect\n\n%default total\n%access public export\n\ndata TyRig = None | One | Tonne\n\nnoneNotOne : (None = One) -> Void\nnoneNotOne Refl impossible\n\nnoneNotTonne : (None = Tonne) -> Void\nnoneNotTonne Refl impossible\n\noneNotTonne : (One = Tonne) -> Void\noneNotTonne Refl impossible\n\nDecEq TyRig where\n decEq None None = Yes Refl\n decEq None One = No noneNotOne\n decEq None Tonne = No noneNotTonne\n decEq One None = No (negEqSym noneNotOne)\n decEq One One = Yes Refl\n decEq One Tonne = No oneNotTonne\n decEq Tonne None = No (negEqSym noneNotTonne)\n decEq Tonne One = No (negEqSym oneNotTonne)\n decEq Tonne Tonne = Yes Refl\n\n\nexport\nplus : TyRig -> TyRig -> TyRig\nplus None None = None\nplus None One = One\nplus None Tonne = Tonne\nplus One None = One\nplus One One = Tonne\nplus One Tonne = Tonne\nplus Tonne None = Tonne\nplus Tonne One = Tonne\nplus Tonne Tonne = Tonne\n\nexport\nmultiply : TyRig -> TyRig -> TyRig\nmultiply None None = None\nmultiply None One = None\nmultiply None Tonne = None\nmultiply One None = None\nmultiply One One = One\nmultiply One Tonne = Tonne\nmultiply Tonne None = None\nmultiply Tonne One = Tonne\nmultiply Tonne Tonne = Tonne\n\nexport\nproduct : Vect n TyRig -> Vect n TyRig -> Vect n TyRig\nproduct [] [] = []\nproduct (x :: xs) (y :: ys) = multiply x y :: product xs ys\n\nexport\nsum : Vect n TyRig -> Vect n TyRig -> Vect n TyRig\nsum [] [] = []\nsum (x :: xs) (y :: ys) = plus x y :: sum xs ys\n", "meta": {"hexsha": "87b0390a727e88214e35da317cf426471498f58f", "size": 1449, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Commons/Data/Rig.idr", "max_stars_repo_name": "jfdm/idris-common", "max_stars_repo_head_hexsha": "df32dc33c253709751fe0f9f2b57cd5d497eccd4", "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": "Commons/Data/Rig.idr", "max_issues_repo_name": "jfdm/idris-common", "max_issues_repo_head_hexsha": "df32dc33c253709751fe0f9f2b57cd5d497eccd4", "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": "Commons/Data/Rig.idr", "max_forks_repo_name": "jfdm/idris-common", "max_forks_repo_head_hexsha": "df32dc33c253709751fe0f9f2b57cd5d497eccd4", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-02-17T14:43:42.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-17T14:43:42.000Z", "avg_line_length": 22.640625, "max_line_length": 59, "alphanum_fraction": 0.7053140097, "num_tokens": 476, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8499711604559846, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.5626153549185823}}
{"text": "import Data.List\n\nInput : Type\nInput = ((Int, Int), (Int, Int))\n\npart1 : Input -> IO String\npart1 (_, (ymin, _)) = pure $ show $ (\\v => (v * (v + 1)) `div` 2) $ abs $ ymin + 1\n\ninTarget : (Int, Int) -> Input -> (Int, Int) -> Bool\ninTarget (x, y) i@((xmin, xmax), (ymin, ymax)) (vx, vy) =\n (xmin <= x && x <= xmax && ymin <= y && y <= ymax) ||\n (x <= xmax && y >= ymin && inTarget (x + vx, y + vy) i (max 0 (vx - 1), vy - 1))\n\npart2 : Input -> IO String\npart2 i@((xmin, xmax), (ymin, ymax)) = do let xs = rangeFromTo 0 xmax\n let ys = rangeFromTo ymin (abs $ ymin + 1)\n pure $ show $ length $ filter (inTarget (0,0) i) $ join $ (\\x => (x,) <$> ys) <$> xs\n\nmain : IO ()\nmain = do let a = ((14, 50), (-267, -225))\n part1 a >>= putStrLn\n part2 a >>= putStrLn\n\n", "meta": {"hexsha": "6a9c632bd3d9f356c31ef75a83dc78d49a6312b6", "size": 857, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "17/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": "17/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": "17/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": 35.7083333333, "max_line_length": 126, "alphanum_fraction": 0.4597432905, "num_tokens": 289, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.84997116805678, "lm_q2_score": 0.6619228691808012, "lm_q1q2_score": 0.5626153542811008}}
{"text": "module Hedgehog.Internal.Util\n\nimport Data.DPair\nimport Data.List\nimport Data.Colist\n\n%default total\n--------------------------------------------------------------------------------\n-- SafeDiv\n--------------------------------------------------------------------------------\n\n||| Interface providing a safe (total) division operation\n||| by proving that the divisor is non-zero.\npublic export\ninterface Neg a => SafeDiv (0 a : Type) (0 pred : a -> Type) | a where\n total safeDiv' : (n,d : a) -> (0 prf : pred d) -> a\n\npublic export\nSafeDiv Int (\\d => d == 0 = False) where\n safeDiv' n d _ = n `div` d\n\npublic export\nSafeDiv Integer (\\d => d == 0 = False) where\n safeDiv' n d _ = n `div` d\n\npublic export\nSafeDiv Double (\\d => d == 0 = False) where\n safeDiv' n d _ = n / d\n\npublic export total\nsafeDiv : SafeDiv a pred => (n,d : a) -> {auto 0 ok : pred d} -> a\nsafeDiv n d = safeDiv' n d ok\n\npublic export total\nfromPred : (a -> Bool) -> a -> Maybe a\nfromPred p a = guard (p a) $> a\n\n--------------------------------------------------------------------------------\n-- ToInteger\n--------------------------------------------------------------------------------\n\npublic export\ninterface Num a => ToInteger a where\n toInteger : a -> Integer\n\n toNat : a -> Nat\n toNat = integerToNat . toInteger\n\npublic export\nToInteger Integer where toInteger = id\n\npublic export\nToInteger Int8 where toInteger = cast\n\npublic export\nToInteger Int16 where toInteger = cast\n\npublic export\nToInteger Int32 where toInteger = cast\n\npublic export\nToInteger Int64 where toInteger = cast\n\npublic export\nToInteger Int where toInteger = cast\n\npublic export\nToInteger Bits8 where toInteger = cast\n\npublic export\nToInteger Bits16 where toInteger = cast\n\npublic export\nToInteger Bits32 where toInteger = cast\n\npublic export\nToInteger Bits64 where toInteger = cast\n\npublic export\nToInteger Nat where\n toInteger = cast\n toNat = id\n\npublic export\nToInteger Double where toInteger = cast\n\npublic export\nfromIntegral : ToInteger a => Num b => a -> b\nfromIntegral = fromInteger . toInteger\n\npublic export\nround : Num a => Double -> a\nround v = let f = floor v\n v' = if v - f < 0.5 then f else ceiling v\n in fromInteger $ cast v'\n\n--------------------------------------------------------------------------------\n-- (Lazy) List Utilities\n--------------------------------------------------------------------------------\n\npublic export\niterateBefore : (p : a -> Bool) -> (a -> a) -> (v : a) -> Colist a\niterateBefore p f = takeBefore p . iterate f\n\npublic export\niterateBefore0 : Eq a => Num a => (a -> a) -> (start : a) -> Colist a\niterateBefore0 = iterateBefore (0 ==)\n\n||| Prepends the first list in reverse order to the\n||| second list.\npublic export\nprepRev : List a -> List a -> List a\nprepRev [] ys = ys\nprepRev (x :: xs) ys = prepRev xs (x :: ys)\n\npublic export\nsignum : Ord a => Neg a => a -> a\nsignum x = if x < 0\n then (-1)\n else if x == 0 then 0 else 1\n\n--------------------------------------------------------------------------------\n-- Colists\n--------------------------------------------------------------------------------\n\n||| Cons an element on to the front of a list unless it is already there.\npublic export total\nconsNub : Eq a => a -> Colist a -> Colist a\nconsNub x [] = [x]\nconsNub x l@(y :: xs) = if x == y then l else x :: l\n\npublic export\nconcatColist : Colist (Colist a) -> Colist a\nconcatColist ((x :: xs) :: ys) = x :: concatColist (xs :: ys)\nconcatColist ([] :: (x :: xs) :: ys) = x :: concatColist (xs :: ys)\nconcatColist _ = []\n\npublic export\nconcatMapColist : (a -> Colist b) -> Colist a -> Colist b\nconcatMapColist f = concatColist . map f\n\npublic export\nfromFoldable : Foldable f => f a -> Colist a\nfromFoldable = fromList . toList\n\n--------------------------------------------------------------------------------\n-- Numeric Utilities\n--------------------------------------------------------------------------------\n\npublic export\nIsInUnit : Double -> Bool\nIsInUnit d = 0.0 < d && d < 1.0\n\npublic export\n0 InUnit : Type\nInUnit = Subset Double (\\x => IsInUnit x = True)\n\nexport\nrecipBits64 : Subset Bits64 (\\x => x >= 2 = True) -> InUnit\nrecipBits64 (Element v _) =\n Element (1.0 / fromInteger (cast v)) (believe_me (Refl {x = True} ))\n\n-- Algorithm taken from\n-- https://web.archive.org/web/20151110174102/http://home.online.no/~pjacklam/notes/invnorm/\n-- Accurate to about one part in 10^9.\n--\n-- The 'erf' package uses the same algorithm, but with an extra step\n-- to get a fully accurate result, which we skip because it requires\n-- the 'erfc' function.\nexport\ninvnormcdf : (p : InUnit) -> Double\ninvnormcdf (Element p _) =\n let a1 = -3.969683028665376e+01\n a2 = 2.209460984245205e+02\n a3 = -2.759285104469687e+02\n a4 = 1.383577518672690e+02\n a5 = -3.066479806614716e+01\n a6 = 2.506628277459239e+00\n\n b1 = -5.447609879822406e+01\n b2 = 1.615858368580409e+02\n b3 = -1.556989798598866e+02\n b4 = 6.680131188771972e+01\n b5 = -1.328068155288572e+01\n\n c1 = -7.784894002430293e-03\n c2 = -3.223964580411365e-01\n c3 = -2.400758277161838e+00\n c4 = -2.549732539343734e+00\n c5 = 4.374664141464968e+00\n c6 = 2.938163982698783e+00\n\n d1 = 7.784695709041462e-03\n d2 = 3.224671290700398e-01\n d3 = 2.445134137142996e+00\n d4 = 3.754408661907416e+00\n\n p_low = 0.02425\n p_high = 1 - p_low\n q = sqrt(-2*log(p))\n\n in if p < p_low\n then (((((c1*q+c2)*q+c3)*q+c4)*q+c5)*q+c6) /\n ((((d1*q+d2)*q+d3)*q+d4)*q+1)\n else\n if p <= p_high\n then\n let\n q = p - 0.5\n r = q*q\n in\n (((((a1*r+a2)*r+a3)*r+a4)*r+a5)*r+a6)*q /\n (((((b1*r+b2)*r+b3)*r+b4)*r+b5)*r+1)\n else\n let\n q = sqrt(-2*log(1-p))\n in\n -(((((c1*q+c2)*q+c3)*q+c4)*q+c5)*q+c6) /\n ((((d1*q+d2)*q+d3)*q+d4)*q+1)\n", "meta": {"hexsha": "c79eec971a173fe8356dc1ddd8bb2255f93bf8ad", "size": 6154, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Hedgehog/Internal/Util.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/Hedgehog/Internal/Util.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/Hedgehog/Internal/Util.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": 27.9727272727, "max_line_length": 92, "alphanum_fraction": 0.523399415, "num_tokens": 1793, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195152660687, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.5625511178137346}}
{"text": "import Data.Vect\nimport Data.Vect.Elem\n\n-- removeElem : {n : _ } -> (value : a) -> (xs : Vect (S n) a) -> (prf : Elem value xs) -> Vect n a\n-- removeElem value (value :: xs) Here = xs\n-- removeElem {n = Z} value (y :: []) (There later) = absurd later\n-- removeElem {n = (S k)} value (y :: xs) (There later) = y :: removeElem value xs later\n\n-- removeElem_auto : {n : _} -> (value : a) -> \n-- (xs : Vect (S n) a) -> \n-- (prf : Elem value xs) =>\n-- Vect n a\n-- removeElem_auto value xs = removeElem value xs prf\n\npublic export\nremoveElem : {n : _ } -> \n (value : a) -> \n (xs : Vect (S n) a) -> \n (prf : Elem value xs) => \n Vect n a\nremoveElem value (value :: xs) {prf = Here} = xs\nremoveElem {n = Z} value (y :: []) {prf = (There later)} = absurd later\nremoveElem {n = (S k)} value (y :: xs) {prf = (There later)} = y :: removeElem value xs\n\n\n", "meta": {"hexsha": "e6e91d6e57b50eaea744851e9eb50a3b26039228", "size": 943, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/ch9/RemoveElem.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/ch9/RemoveElem.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/ch9/RemoveElem.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": 36.2692307692, "max_line_length": 99, "alphanum_fraction": 0.506892895, "num_tokens": 300, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916134888613, "lm_q2_score": 0.6513548511303338, "lm_q1q2_score": 0.5623743158712159}}
{"text": "module TwoThreeTree\n%access abstract\n\ndata TwoThreeTree : Type -> Type where\n Nil : TwoThreeTree a\n Leaf : a -> TwoThreeTree a\n Node : a -> a -> TwoThreeTree a -> TwoThreeTree a \n -> Maybe (TwoThreeTree a) -> TwoThreeTree a\n \n-- Lookup value\nlookup : (Eq a, Ord a) => a -> TwoThreeTree a -> Bool\nlookup x Nil = False\nlookup x (Leaf r) = (x == r)\nlookup x (Node lm mm lc mc rc) = \n if x <= lm then\n lookup x lc\n else\n if (x > lm) && (x <= mm) then\n lookup x mc\n else\n case rc of\n Nothing => False\n Just tt => lookup x tt\n\n-- Tree2List function\nTree2List : TwoThreeTree a -> List a\nTree2List Nil = []\nTree2List (Leaf x) = [x]\nTree2List (Node x y z w Nothing) = (Tree2List z) ++ (Tree2List w)\nTree2List (Node x y z w (Just s)) = (Tree2List z) ++ (Tree2List w) ++ (Tree2List s)\n\nShow a => Show (TwoThreeTree a) where\n show x = show (Tree2List x)\n\nprivate\nget_max : (Ord a) => TwoThreeTree a -> a -> a\nget_max tree val = \n case (head' ll, tail' ll) of\n (Nothing, Nothing) => val\n (Just h, Just t) => foldl max h t\n where\n ll : List a\n ll = Tree2List tree\n\nprivate\nupdate_lm_mm : Ord a => TwoThreeTree a -> TwoThreeTree a\nupdate_lm_mm Nil = Nil\nupdate_lm_mm (Leaf x) = Leaf x\nupdate_lm_mm (Node _ _ (Leaf u) (Leaf v) y1) = \n Node u v (Leaf u) (Leaf v) y1\nupdate_lm_mm (Node _ mm (Leaf u) mst y1) = \n Node u (get_max mst mm) (Leaf u) mst y1\nupdate_lm_mm (Node lm _ lst (Leaf s1) y1) = \n Node (get_max lst lm) s1 lst (Leaf s1) y1\nupdate_lm_mm (Node lm mm lst mst y1) = \n Node (get_max lst lm) (get_max mst mm) lst mst y1 \n\nprivate\ninsert : Ord a => a -> TwoThreeTree a \n -> (TwoThreeTree a, Maybe(TwoThreeTree a))\ninsert x Nil = (Leaf x, Nothing)\ninsert x (Leaf y) = \n if y <= x then\n (Node y x (Leaf y) (Leaf x) Nothing, Nothing)\n else\n (Node x y (Leaf x) (Leaf y) Nothing, Nothing)\n\ninsert x y = insert' x y where\n insert' : a -> TwoThreeTree a \n -> (TwoThreeTree a, Maybe (TwoThreeTree a))\n insert' x (Node y z (Leaf w) (Leaf s) t) = \n insert'' x y z w s t where\n insert'' : a -> a -> a -> a -> a -> Maybe (TwoThreeTree a) \n -> (TwoThreeTree a, Maybe (TwoThreeTree a))\n insert'' x lm mm lsl msl Nothing =\n if x <= lm then\n (Node x lm (Leaf x) (Leaf lsl) (Just (Leaf msl)), Nothing)\n else\n if (x > lm) && (x <= mm) then\n (Node lm x (Leaf lsl) (Leaf x) (Just (Leaf msl)), Nothing)\n else\n (Node lm mm (Leaf lsl) (Leaf msl) (Just (Leaf x)), Nothing)\n insert'' k lm mm lf mf (Just (Leaf rf)) =\n if k <= lm then\n (Node k lm (Leaf k) (Leaf lm) Nothing, -- This is node n\n Just (Node mm rf (Leaf mm) (Leaf rf) Nothing)) -- This is node m\n else \n if (k > lm) && (k <= mm) then\n (Node lm k (Leaf lm) (Leaf k) Nothing,\n Just (Node mm rf (Leaf mm) (Leaf rf) Nothing))\n else\n if (k > mm) && (k <= rf) then\n (Node lm mm (Leaf lm) (Leaf mm) Nothing,\n Just (Node k rf (Leaf k) (Leaf rf) Nothing))\n else\n (Node lm mm (Leaf lm) (Leaf mm) Nothing,\n Just (Node rf k (Leaf rf) (Leaf k) Nothing))\n\n -- TODO This should never happen, because all leaves are the same\n -- level!\n -- insert'' x y z x1 y1 (Just (Node u v z1 w1 s1)) = ?b_2\n \n insert' x (Node y z lst mst t) = \n if x <= y then\n let (n, m) = insert x lst in\n case m of\n Nothing => (Node y z n mst t, Nothing)\n Just m => \n case t of\n Nothing => (Node y z n m (Just mst), Nothing)\n Just m1 => (Node y z n m (Just mst), Just m1)\n else\n if (x > y) && (x <= z) then\n let (n, m) = insert x mst in\n case m of\n Nothing => (Node y z lst n t, Nothing)\n Just m =>\n case t of\n Nothing => (Node y z lst n (Just m), Nothing)\n Just m1 => (Node y z lst n (Just m), Just m1)\n else\n case t of\n Just u => \n let (n, m) = insert x u in\n case m of\n Nothing => (Node y z lst mst (Just n), Nothing) \n Just w => (Node y z lst mst (Just n), Just w)\n Nothing => \n let (n, m) = insert x mst in\n case m of\n Nothing => (Node y z lst n Nothing, Nothing)\n Just w => (Node y z lst n Nothing, m)\n\nprivate\nget : Ord a => TwoThreeTree a -> a\nget (Leaf x) = x\nget (Node x y z w s) = max x y\n\n-- Insert function XXX: Make this update_lm_mm inlined with insertion\n-- itself!\nInsert : Ord a => a -> TwoThreeTree a -> TwoThreeTree a\nInsert x y = \n if (lookup x y) /= True then\n let (n, m) = insert x y in\n case m of\n Nothing => update_lm_mm n\n Just m => update_lm_mm (Node (get n) (get m) n m Nothing)\n else y\n\n-- Functor on TwoThreeTree\nFunctor TwoThreeTree where\n map f Nil = Nil\n map f (Leaf x) = Leaf (f x)\n map f (Node x y z w Nothing) = Node (f x) (f y) (map f z) (map f w) Nothing\n map f (Node x y z w (Just s)) = Node (f x) (f y) (map f z) (map f w) \n (Just (assert_total (map f s)))\n \n \nprivate \ndelete' : (Ord a, Eq a) => a -> TwoThreeTree a -> (TwoThreeTree a, Bool)\n\n-- This is the case where there are 3 children\ndelete' k (Node y z (Leaf w) (Leaf s) (Just t)) = \n -- Remove the left leaf\n if k == w then\n (Node z (get_val t) (Leaf s) t Nothing, False)\n else\n -- Remove the middle leaf\n if k == s then\n (Node y (get_val t) (Leaf w) t Nothing, False)\n -- Remove the right leaf\n else\n (Node y z (Leaf w) (Leaf s) Nothing, False) where\n get_val : TwoThreeTree a -> a\n get_val (Leaf x) = x\n\n-- This is the case where there are only 2 children\ndelete' k (Node y z (Leaf w) (Leaf s) Nothing) = \n if (k == y) || (k == z) then\n (Node y z (Leaf w) (Leaf s) Nothing, True)\n else\n (Node y z (Leaf w) (Leaf s) Nothing, False)\n \n-- Still need to recurse trying to find the leafs!\ndelete' k (Node y z lst mst t) = \n if k <= y then\n case delete' k lst of\n (tt, True) => \n case mst of\n Node _ _ _ _ (Just _) => (delete'' k y z lst mst t, False)\n Node _ _ _ _ Nothing => \n case t of\n Just (Node na nb nc nd (Just ne)) => \n (delete'' k y z lst (Node na nb nc nd (Just ne)) (Just mst), False)\n Just (Node _ _ _ _ Nothing) => (delete''' k y z lst mst t, False)\n -- In this case when lst is deleted only one node mst will\n -- remain and the tree will be unbalanced.\n Nothing => (delete''' k y z lst mst t, False)\n (tt, False) => (Node y z tt mst t, False)\n else\n if (k > y) && (k <= z) then\n case delete' k mst of \n (tt, True) => \n case lst of\n Node _ _ _ _ (Just _) => (delete'' k y z mst lst t, False)\n Node _ _ _ _ Nothing => \n case t of\n Just (Node na nb nc nd (Just ne)) => \n (delete'' k y z mst (Node na nb nc nd (Just ne)) (Just lst), False)\n Just (Node _ _ _ _ Nothing) => (delete''' k y z mst lst t, False)\n -- In this case when mst is deleted then there will be a\n -- single node left just lst\n Nothing => (delete''' k y z mst lst t, False)\n (tt, False) => (Node y z lst tt t, False)\n else\n case t of\n Just ttt => \n case delete' k ttt of\n (tt, True) => \n case lst of\n Node _ _ _ _ (Just _) => (delete'' k y z ttt lst (Just mst), False)\n Node _ _ _ _ Nothing => \n case mst of\n Node _ _ _ _ (Just _) => (delete'' k y z ttt mst (Just lst), False)\n Node _ _ _ _ Nothing => (delete''' k y z ttt lst (Just mst), False)\n (tt, False) => (Node y z lst mst (Just tt), False)\n Nothing => (Node y z lst mst t, False) \n where\n -- The case when the sibling has 3 kids\n delete'' : (k : a) -> (lm : a) -> (mm : a) -> (td : TwoThreeTree a) \n -> (sibling : TwoThreeTree a) -> (xtra: Maybe (TwoThreeTree a))\n -> TwoThreeTree a\n delete'' k lm mm td sibling xtra = \n let (nsibling, sc) = steal_third_child sibling in\n Node lm mm (remove_k_td k td sc) nsibling xtra\n where\n -- This is the only case that should happen here!\n steal_third_child : TwoThreeTree a -> (TwoThreeTree a, TwoThreeTree a)\n steal_third_child (Node x w s u (Just v)) = (Node x w s u Nothing, v)\n \n -- Here we need to delete \"Leaf k\" and replace it with sc\n remove_k_td : (Eq a, Ord a) => (k : a) -> (td : TwoThreeTree a) \n -> (sc : TwoThreeTree a) -> TwoThreeTree a\n remove_k_td k (Node x w (Leaf s) (Leaf u) Nothing) sc = \n let scv = get_val sc in\n if k == s then\n if w <= scv then\n Node w scv (Leaf u) sc Nothing\n else\n Node scv w sc (Leaf u) Nothing\n else\n if x <= scv then\n Node x scv (Leaf s) sc Nothing\n else\n Node scv x sc (Leaf x) Nothing\n where\n get_val : TwoThreeTree a -> a\n get_val (Leaf vv) = vv\n \n -- The case when the siblings only have 2 kids\n delete''' : (k : a) -> (lm : a) -> (mm : a) -> (td : TwoThreeTree a)\n -> (sibling : TwoThreeTree a) -> (xtra : Maybe (TwoThreeTree a))\n -> TwoThreeTree a\n delete''' k lm mm td sibling xtra = \n let nsibling = Insert (remove_k_from_td k td) sibling in \n return_tree lm mm nsibling xtra\n where\n remove_k_from_td : a -> TwoThreeTree a -> a\n remove_k_from_td k (Node _ _ (Leaf ll) (Leaf rl) Nothing) = \n if k == ll then rl else ll\n\n return_tree : a -> a -> TwoThreeTree a -> Maybe (TwoThreeTree a)\n -> TwoThreeTree a\n return_tree lm mm nsibling Nothing = nsibling\n -- XXX: This should be updated later on!\n return_tree lm mm nsibling (Just xxtra) = Node lm mm nsibling xxtra Nothing\n\n-- Delete a key from the TwoThreeTree\nDelete : (Eq a, Ord a) => a -> (TwoThreeTree a) -> TwoThreeTree a\nDelete x [] = []\nDelete x (Leaf y) = \n if x == y then []\n else (Leaf y)\nDelete x t = \n if (lookup x t) then\n case (delete' x t) of\n (t, True) => remove_from_root t\n (t, False) => update_lm_mm t\n else \n t where\n remove_from_root : TwoThreeTree a -> TwoThreeTree a\n remove_from_root [] = []\n remove_from_root (Leaf x) = (Leaf x)\n remove_from_root (Node lm mm (Leaf l) (Leaf m) Nothing) = \n if x == l then\n Leaf m\n else Leaf l\n \n\n-- Examples\naTwoThreeTree : TwoThreeTree Nat\naTwoThreeTree = (Node 10 11 (Node 8 9 (Leaf 8) (Leaf 9) (Just (Leaf 10))) \n (Leaf 11) Nothing)\n\n-- Example of insert\nct : TwoThreeTree Nat\nct = map (+ 1) (Node 10 14 (Leaf 10) (Leaf 14) (Just (Leaf 15)))\n\nbt : TwoThreeTree Nat\nbt = Insert 17 ct\n\ndt : TwoThreeTree Nat\ndt = Insert 18 bt\n \net : TwoThreeTree Nat\net = Insert 19 dt\n\nft : TwoThreeTree Nat\nft = Insert 14 dt\n \n-- Examples of delete\ngt : TwoThreeTree Nat\ngt = Delete 18 ft\n\nht : TwoThreeTree Nat\nht = Delete 11 gt\n", "meta": {"hexsha": "a35f6fe1b9f7fe8d1bae6b04d2603c60155dd967", "size": 11065, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "TwoThreeTree.idr", "max_stars_repo_name": "amal029/idris-data-structures", "max_stars_repo_head_hexsha": "b11cbae154f3c0cc6695756849310384e9955ea8", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2020-10-03T18:19:36.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-03T18:19:36.000Z", "max_issues_repo_path": "TwoThreeTree.idr", "max_issues_repo_name": "amal029/idris-data-structures", "max_issues_repo_head_hexsha": "b11cbae154f3c0cc6695756849310384e9955ea8", "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": "TwoThreeTree.idr", "max_forks_repo_name": "amal029/idris-data-structures", "max_forks_repo_head_hexsha": "b11cbae154f3c0cc6695756849310384e9955ea8", "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.8379204893, "max_line_length": 87, "alphanum_fraction": 0.5495707185, "num_tokens": 3497, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.7090191337850933, "lm_q1q2_score": 0.5623272945083615}}
{"text": "module PurelyFunctionalState\n\nimport Verified\n\n||| The State Functor, abstracts all the combinators\n||| We'll be using in this chapter\n|||\ndata MyState s a =\n StateAction (s -> (a, s))\n\n||| To fold MyState s a into (a, s) you need to give it an initial state\n|||\nrunMyState : MyState s a -> s -> (a, s)\nrunMyState (StateAction action) = action\n\n||| Like runMyState except that it drops the value and just returns the final state\n|||\nexecMyState : MyState s a -> s -> s\nexecMyState ma st = snd (runMyState ma st)\n\n-- Need to define the combinators, we're in a strict environment, so you have to start from the most\n-- generic one and work your way down...\n\nbindMyState : MyState s a -> (a -> MyState s b) -> MyState s b\nbindMyState mx f = StateAction stateAction\n where\n stateAction : s -> (b, s)\n stateAction st = let (x, st1) = runMyState mx st in runMyState (f x) st1\n\npureMyState : a -> MyState s a\npureMyState x = StateAction (\\st => (x, st))\n\nmapMyState : (a -> b) -> MyState s a -> MyState s b\nmapMyState f mx = bindMyState mx (pureMyState . f)\n\nlift2MyState : (a -> b -> c) -> MyState s a -> MyState s b -> MyState s c\nlift2MyState g mx my = bindMyState mx (\\x => bindMyState my (\\y => pureMyState (g x y)))\n\napplyMyState : MyState s (a -> b) -> MyState s a -> MyState s b\napplyMyState = lift2MyState id\n\n-- instances\n\ninstance Functor (MyState s) where\n map = mapMyState\n\ninstance VerifiedFunctor (MyState s) where\n mapIdentity fa = ?mapIdentityMyState_rhs\n mapComposition fa k g = ?mapCompositionMyState_rhs\n\ninstance Applicative (MyState s) where\n pure = pureMyState\n (<*>) = applyMyState\n\n||| a lot of these are hard to prove without a notion of extensional equality for functions,\n||| since these proofs wont be used in programs,\n||| I'm happy to cheat with believe_me.\n|||\nextensionalEquality : (f : a -> b) -> (g : a -> b) -> (x : a) -> (f x = g x )-> f = g\nextensionalEquality f g x = believe_me\n\ninstance VerifiedApplicative (MyState s) where\n applicativePureId v = ?applicativePureIdMyState_rhs\n\n applicativeComposition (StateAction u) (StateAction v) (StateAction w) = ?applicativeCompositionMyState_rhs\n\n applicativeHomomorphism k x = ?applicativeHomomorphismMyState_rhs\n\n applicativeInterchange u y = ?applicativeInterchangeMyState_rhs\n\ninstance Monad (MyState s) where\n (>>=) = bindMyState\n\ninstance VerifiedMonad (MyState s) where\n monadPureIdentityL k x = ?monadPureIdentityLMyState_rhs\n\n monadPureIdentityR ma = ?monadPureIdentityLMyState_rhs\n\n monadBindAssociative k h ma = ?monadBindAssociativeMyState_rhs\n\n monadBindApplySame f mx my = ?monadBindApplySameMyState_rhs\n\n-- exercises\n\n-- I skipped the RNG related exercises as Idris' RNG and Int manipulation functions are sort of immature.\n\n||| Exercise 6 : Implement map2 for MyState\n|||\ntotal\nmap2 : (a -> b -> c) -> MyState s a -> MyState s b -> MyState s c\nmap2 = lift2MyState\n\n||| Exercise 6 : Implement map2 for MyState\n|||\n||| see map2\n|||\ntotal\nexercise6 : (a -> b -> c) -> MyState s a -> MyState s b -> MyState s c\nexercise6 = map2\n\ntotal\ntraverseMyStateList : (a -> MyState s b) -> List a -> MyState s (List b)\ntraverseMyStateList f xs = foldr (foldFunc f) (pure (the (List b) Nil)) xs\n where\n foldFunc : (a -> MyState s b) -> a -> MyState s (List b) -> MyState s (List b)\n foldFunc g x mys = lift2MyState (::) (g x) mys\n||| Exercise 7 : Implement SequenceList for a list of MyState\n|||\ntotal\nsequenceMyStateList : List (MyState s a) -> MyState s (List a)\nsequenceMyStateList = traverseMyStateList id\n\n||| Exercise 7 : Implement SequenceList for a list of MyState.\n|||\n||| see sequenceMyStateList\n|||\ntotal\nexercise7 : List (MyState s a) -> MyState s (List a)\nexercise7 = sequenceMyStateList\n\n||| Exercise 8 : Implement bindMyState\n|||\n||| see bindMyState\n|||\ntotal\nexercise8 : MyState s a -> (a -> MyState s b) -> MyState s b\nexercise8 = bindMyState\n\n||| Exercise 9 : Reimplement map and map2 in terms of bindMyState,\n||| (I already wrote map2 in terms of bindMyState).\n|||\n|||\ntotal\nmapMyState2 : (a -> b) -> MyState s a -> MyState s b\nmapMyState2 f ma = bindMyState ma (pureMyState . f)\n\n||| Exercise 9 : Reimplement map and map2 in terms of bindMyState,\n||| (I already wrote map2 in terms of bindMyState).\n|||\n||| so see mapMyState2.\n|||\ntotal\nexercise9 : (a -> b) -> MyState s a -> MyState s b\nexercise9 = mapMyState2\n\n-- Exercise 10 is all the Functor, Applicative and Monad functions for MyState.\n-- which is already done, see the Functor, Applicative and Monad instances for\n-- MyState,\n--\n-- Also see sequenceMyStateList\n\n||| State type for Exercise 11\ndata CoinMachineState = CoinMachineS Bool Int Int\n\ntotal\nisLocked : CoinMachineState -> Bool\nisLocked (CoinMachineS b x y) = b\n\ntotal\ncandies : CoinMachineState -> Int\ncandies (CoinMachineS b x y) = x\n\ntotal\ncoins : CoinMachineState -> Int\ncoins (CoinMachineS b x y) = y\n\ndata MachineAction = InsertCoin | TurnKnob\n\n||| Common function for MyState, gets the value of the State\n|||\ntotal\ngetMyState : MyState s s\ngetMyState = StateAction (\\x => (x, x))\n\n||| applies a function to the state and returns the result\n|||\ntotal\ngetsMyState : (s -> a) -> MyState s a\ngetsMyState f = mapMyState f getMyState\n\n||| This function allows you to write to the state\n|||\ntotal\nputMyState : s -> MyState s ()\nputMyState newState = StateAction (\\oldState => ((), newState))\n\n||| Given a conditional, will run the applicative action unless the conditional is False\n|||\n||| @ b The Conditional\n||| @ action the action to run when the conditional is False\n|||\ntotal\nunlessA : (Applicative f) => (b : Bool) -> (action : f ()) -> f ()\nunlessA b action = if b then pure () else action\n\ntotal\nisOutOfCandy : MyState CoinMachineState Bool\nisOutOfCandy = do\n candyCount <- getsMyState candies\n pure (candyCount == 0)\n\ntotal\nifCandy : MyState CoinMachineState () -> MyState CoinMachineState ()\nifCandy action = do\n isOut <- isOutOfCandy\n unlessA isOut action\n\ntotal\nifUnlocked : MyState CoinMachineState () -> MyState CoinMachineState ()\nifUnlocked action = do\n locked <- getsMyState isLocked\n unlessA locked action\n\ntotal\nifLocked : MyState CoinMachineState () -> MyState CoinMachineState ()\nifLocked action = do\n locked <- getsMyState isLocked\n when locked action\n\n\ntotal\nrunAction : MachineAction -> MyState CoinMachineState ()\nrunAction InsertCoin = ifCandy (\n do\n coins' <- getsMyState coins\n candies' <- getsMyState candies\n putMyState (CoinMachineS False candies' (coins' + 1))\n )\nrunAction TurnKnob = ifCandy (ifUnlocked (\n do\n coins' <- getsMyState coins\n candies' <- getsMyState candies\n putMyState (CoinMachineS True (candies' - 1) coins')\n ))\n\ninitialState : Int -> Int -> CoinMachineState\ninitialState = CoinMachineS True\n\n||| Exercise 11 - simulateMachine\n|||\ntotal\nsimulationMachine : (candy : Int) -> (coin : Int) -> (actions : List MachineAction) -> CoinMachineState\nsimulationMachine candy coin = flip execMyState (initialState candy coin) . traverseMyStateList runAction\n", "meta": {"hexsha": "13d1897f31b1da4a0c7a399c43d038192ada2028", "size": 7071, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "data/github.com/domdere/fp-in-idris/3ce58d2a8a6c9788b1bb71328f1fcef9c8f4d192/src/PurelyFunctionalState.idr", "max_stars_repo_name": "ajnavarro/language-dataset", "max_stars_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 9, "max_stars_repo_stars_event_min_datetime": "2018-08-07T11:54:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-11T09:48:45.000Z", "max_issues_repo_path": "data/github.com/domdere/fp-in-idris/3ce58d2a8a6c9788b1bb71328f1fcef9c8f4d192/src/PurelyFunctionalState.idr", "max_issues_repo_name": "ajnavarro/language-dataset", "max_issues_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 91, "max_issues_repo_issues_event_min_datetime": "2019-11-11T15:41:26.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-21T04:17:18.000Z", "max_forks_repo_path": "data/github.com/domdere/fp-in-idris/3ce58d2a8a6c9788b1bb71328f1fcef9c8f4d192/src/PurelyFunctionalState.idr", "max_forks_repo_name": "ajnavarro/language-dataset", "max_forks_repo_head_hexsha": "34e2980af98ff2ded500619edce3e0907a6e9050", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 3, "max_forks_repo_forks_event_min_datetime": "2019-11-13T12:44:41.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-06T19:34:26.000Z", "avg_line_length": 28.9795081967, "max_line_length": 111, "alphanum_fraction": 0.7011738085, "num_tokens": 2067, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585669110203, "lm_q2_score": 0.7690802264851919, "lm_q1q2_score": 0.5622426882138674}}
{"text": "module Chapter5\n\nimport Naturality\nimport SumsAndProducts\n\n%default total\n\nExercise_5_1_1_product_unit_as_subject : {ccc : CartesianClosedCategory} ->\n {x, a : CCC_object ccc} ->\n CCC_morphism {ccc} x a ->\n CCC_morphism {ccc} x (CCC_product {ccc} (CCC_terminal ccc) a)\nExercise_5_1_1_product_unit_as_subject f =\n CCC_morphism_product (fst (CCC_is_terminal ccc x)) f\n\nExercise_5_1_1_product_unit_subject_change : {ccc : CartesianClosedCategory} ->\n (a : CCC_object ccc) ->\n SubjectChange {cat=(CCC_cat ccc)} (CCC_product {ccc} (CCC_terminal ccc) a) a\nExercise_5_1_1_product_unit_subject_change {ccc} a x f =\n After (CCC_cat ccc) (CCC_second _ _) f\n\nExercise_5_1_1_product_unit_subject_change_is_natural :\n {ccc : CartesianClosedCategory} ->\n (a : CCC_object ccc) ->\n SubjectChangeIsNatural {cat=CCC_cat ccc}\n {subjectA=(CCC_product {ccc} (CCC_terminal ccc) a)}\n {subjectB=a}\n (Exercise_5_1_1_product_unit_subject_change {ccc} a)\nExercise_5_1_1_product_unit_subject_change_is_natural {ccc} a y x g =\n functionalExtensionality (\\f => sym (Associativity _ _ _ _))\n\nExercise_5_1_1_product_unit_isomorphism : {ccc : CartesianClosedCategory} ->\n (a : CCC_object ccc) ->\n CCC_morphism {ccc} (CCC_product {ccc} (CCC_terminal ccc) a) a\nExercise_5_1_1_product_unit_isomorphism {ccc} a =\n SubjectChangeInducedMorphism (Exercise_5_1_1_product_unit_subject_change a)\n\n{- This is not the only choice of arrow with this domain and codomain --\n - see Exercise 5.1.4 below. -}\nExercise_5_1_2 : {ccc : CartesianClosedCategory} -> (a, b : CCC_object ccc) ->\n CCC_morphism {ccc}\n (CCC_sum {ccc} b (CCC_product {ccc} a b))\n (CCC_product {ccc} (CCC_sum {ccc} (CCC_terminal ccc) a) b)\nExercise_5_1_2 {ccc} a b =\n CCC_morphism_product\n (CCC_morphism_sum\n ((CCC_left (CCC_terminal ccc) a) .* fst (CCC_is_terminal ccc b))\n ((CCC_right _ _) .* (CCC_first a b)))\n (CCC_morphism_sum\n (CCC_id b)\n (CCC_second a b))\n\nExercise_5_1_3 : {ccc : CartesianClosedCategory} -> (a, b : CCC_object ccc) ->\n CCC_morphism {ccc}\n (CCC_sum {ccc} b (CCC_product {ccc} a b))\n (CCC_product {ccc} (CCC_sum {ccc} (CCC_terminal ccc) a) b)\nExercise_5_1_3 a b =\n CCC_morphism_sum\n (CCC_morphism_product\n ((CCC_left (CCC_terminal ccc) a) .* fst (CCC_is_terminal ccc b))\n (CCC_id b))\n (CCC_morphism_product\n ((CCC_right _ _) .* (CCC_first a b))\n (CCC_second a b))\n\nExercise_5_1_4_maybe_AB : {a, b : Type} -> Either b (a, b) -> (Maybe a, b)\nExercise_5_1_4_maybe_AB (Left y) = (Nothing, y)\nExercise_5_1_4_maybe_AB (Right (x, y)) = (Just x, y)\n\n{- The type signature for Exercise 5.1.4 allows a bit of leeway --\n - but not much: -}\nExercise_5_1_4_maybe_AB_alternate :\n {a, b : Type} -> Either b (a, b) -> (Maybe a, b)\n{- We have no choice aboue this one: we have no witness for type \"a\", so the\n - only \"Maybe a\" we can come up with is \"Nothing\". And we have only one\n - witness for type \"b\", so we have to choose that. -}\nExercise_5_1_4_maybe_AB_alternate (Left y) = (Nothing, y)\n{- Here we do have one alternative: even though we have a witness for type \"a\"\n - in this case, we could choose not to use it, and to return \"Nothing\"\n - anyway. -}\nExercise_5_1_4_maybe_AB_alternate (Right (_, y)) = (Nothing, y)\n", "meta": {"hexsha": "96ccbe836f048a95f229962521ef34c177e8f153", "size": 3374, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Chapter5.idr", "max_stars_repo_name": "rokopt/dao-fp-exercises", "max_stars_repo_head_hexsha": "e5291ca45015c4ee5af49c0d8a256cf7da5b08c1", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 6, "max_stars_repo_stars_event_min_datetime": "2021-01-17T17:12:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T03:52:36.000Z", "max_issues_repo_path": "src/Chapter5.idr", "max_issues_repo_name": "rokopt/dao-fp-exercises", "max_issues_repo_head_hexsha": "e5291ca45015c4ee5af49c0d8a256cf7da5b08c1", "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/Chapter5.idr", "max_forks_repo_name": "rokopt/dao-fp-exercises", "max_forks_repo_head_hexsha": "e5291ca45015c4ee5af49c0d8a256cf7da5b08c1", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2021-01-17T17:12:19.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-17T17:12:19.000Z", "avg_line_length": 41.6543209877, "max_line_length": 80, "alphanum_fraction": 0.684943687, "num_tokens": 1045, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8872045966995027, "lm_q2_score": 0.6334102498375401, "lm_q1q2_score": 0.561964485252446}}
{"text": "\n\ndata Direction = North | East | South | West\n\ndata Nat = Z | S Nat\n\nturnClockwise : Direction -> Direction\nturnClockwise North = East\nturnClockwise East = South\nturnClockwise South = West\nturnClockwise West = North\n\n", "meta": {"hexsha": "163045e9b7e378c46564e49faca73811cc1743e6", "size": 218, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Chapter4/direction.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": "Chapter4/direction.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": "Chapter4/direction.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": 16.7692307692, "max_line_length": 44, "alphanum_fraction": 0.7431192661, "num_tokens": 56, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.795658090372256, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.5615635674621259}}
{"text": "\nmodule BigStep\n\n-- Relation 'BigStep' for fully reducing terms\n-- in the untyped lambda calculus to values.\n \n\nimport Term\nimport Subst\n\n\n%default total\n%access public export\n\n\n-----------------------------------------------------------------------\n-- Begin: BIG-STEP EVALUATION RELATION FOR TERMS IN THE LAMBDA CALCULUS\n\n-- The relation 'BigStep' defines evaluation of terms in the lambda\n-- calculus following big-step semantics.\n--\n-- Big-step semantics fully evaluates terms to values.\n-- (A proof of this statement appears below.)\ndata BigStep : Term 0 -> (y: Term 0) -> Type where\n BStValue : (v : Value e) -> BigStep e e\n --\n BStApp : BigStep e1 (TAbs e1') ->\n BigStep e2 e2' ->\n BigStep (subst e2' FZ e1') e ->\n BigStep (TApp e1 e2) e\n --\n BStSucc : BigStep e e' ->\n BigStep (TSucc e) (TSucc e')\n -- \n BStPredZero : BigStep e TZero ->\n BigStep (TPred e) TZero\n -- \n BStPredSucc : BigStep e (TSucc e') ->\n BigStep (TPred e) e'\n -- \n BStIfzZero : BigStep e1 TZero ->\n BigStep e2 e ->\n BigStep (TIfz e1 e2 _) e\n -- \n BStIfzSucc : BigStep e1 (TSucc _) ->\n BigStep e3 e ->\n BigStep (TIfz e1 _ e3) e\n\n\nbigStepFst : {e : Term 0} -> BigStep e _ -> Term 0\nbigStepFst {e = e} _ = e\n\n\nbigStepSnd : {e : Term 0} -> BigStep _ e -> Term 0\nbigStepSnd {e = e} _ = e\n\n\nbigStepValue : BigStep _ e -> Value e\nbigStepValue (BStValue v) = v\nbigStepValue (BStApp _ _ z) = bigStepValue z\nbigStepValue (BStSucc z) = VSucc (bigStepValue z)\nbigStepValue (BStPredZero _) = VZero\nbigStepValue (BStPredSucc z) = case bigStepValue z of\n VZero impossible\n VSucc v => v\nbigStepValue (BStIfzZero _ z) = bigStepValue z\nbigStepValue (BStIfzSucc _ z) = bigStepValue z\n \n-- End: BIG-STEP EVALUATION RELATION FOR TERMS IN THE LAMBDA CALCULUS\n---------------------------------------------------------------------\n\n", "meta": {"hexsha": "67895f532891222339634905a98550b4f338f394", "size": 2114, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "untyped/src/BigStep.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": "untyped/src/BigStep.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": "untyped/src/BigStep.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": 29.3611111111, "max_line_length": 71, "alphanum_fraction": 0.5326395459, "num_tokens": 609, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951182587158, "lm_q2_score": 0.6654105720171531, "lm_q1q2_score": 0.5615367333630151}}
{"text": "module Invertible\n\n%default total\n\n-- http://www.informatik.uni-marburg.de/~rendel/unparse/\n\ndata PartIso α β = MkPartIso (α -> Maybe β) (β -> Maybe α)\n\nclass PartIsoFunctor (f : Type -> Type -> Type) where\n (<$>) : PartIso α β -> (f α γ -> f β γ)\n\ninverse : PartIso α β -> PartIso β α\ninverse (MkPartIso f g) = MkPartIso g f\n\napply : PartIso α β -> α -> Maybe β\napply (MkPartIso f g) = f\n\nunapply : PartIso α β -> β -> Maybe α\nunapply = Invertible.apply . inverse\n\nclass ProductFunctor (f : Type -> Type -> Type) where\n pf : f α γ -> f β γ -> f (α, β) γ\n\nclass Alternative (f : Type -> Type -> Type) where\n alt : f α γ -> f α γ -> f α γ\n empty : f α γ\n\nclass (PartIsoFunctor δ, ProductFunctor δ, Invertible.Alternative δ) => Syntax (δ : Type -> Type -> Type) γ where\n -- (<$>) :: Iso α β → δ α → δ β\n -- (<∗>) :: δ α → δ β → δ (α, β )\n -- (<|>) :: δ α → δ α → δ α\n -- empty :: δ α\n pure : Eq α => α -> δ α γ\n token : δ γ γ\n\n\n\nnilv : PartIso () (Vect 0 α)\nnilv = MkPartIso (const . Just $ Vect.Nil {a=α})\n (\\xs => case xs of\n [] => Just ()\n _ => Nothing)\n\nconsv : PartIso (α, Vect n α) (Vect (S n) α)\nconsv = MkPartIso c1 c2\n where c1 (x, xs) = Just (x :: xs)\n c2 (x :: xs) = Just (x, xs)\n\ntimes : Syntax δ γ => {n : Nat} -> δ α γ -> δ (Vect n α) γ\ntimes {n} p with (n)\n | Z = (nilv <$> (Invertible.pure ()))\n | (S k) = (consv <$> (p `pf` (times p)))\n\n\nnil : PartIso () (List α)\nnil = MkPartIso (const . Just $ List.Nil {a=α})\n (\\xs => case xs of\n [] => Just ()\n _ => Nothing)\n\ncons : PartIso (α, List α) (List α)\ncons = MkPartIso c1 c2\n where c1 (x, xs) = Just (x :: xs)\n c2 [] = Nothing\n c2 (x :: xs) = Just (x, xs)\n\nmany : Syntax δ γ => (max : Nat) -> δ α γ -> δ (List α) γ\nmany Z _ = nil <$> pure ()\nmany (S m) p = nil <$> pure ()\n `alt` cons <$> (pf p (many m p))\n\n\ndata Parser α γ = MkParser (List γ -> List (α, List γ))\n\n\nparse : Parser α γ -> List γ -> List α\nparse (MkParser p) s = [x | (x, _) <- p s]\n\ninstance PartIsoFunctor Parser where\n iso <$> (MkParser p) = MkParser (\\s => [ (y, s')\n | (x, s') <- p s\n , y <- toList $ apply iso x])\n\ninstance ProductFunctor Parser where\n pf (MkParser p) (MkParser q) = MkParser (\\s => [ ((x,y), s'')\n | (x, s') <- p s\n , (y, s'') <- q s'])\n\ninstance Invertible.Alternative Parser where\n alt (MkParser p) (MkParser q) = MkParser (\\s => (p s) ++ (q s))\n empty = MkParser (\\s => List.Nil)\n\ninstance Syntax Parser γ where\n pure x = MkParser (\\s => [(x, s)])\n token = MkParser f\n where\n f [] = []\n f (x :: xs) = [(x, xs)]\n\n\ndata Printer α γ = MkPrinter (α -> Maybe (List γ))\n\nprint : Printer α γ -> α -> Maybe (List γ)\nprint (MkPrinter p) x = p x\n\ninstance PartIsoFunctor Printer where\n iso <$> (MkPrinter p) = MkPrinter (\\b => unapply iso b >>= p)\n\ninstance ProductFunctor Printer where\n pf (MkPrinter p) (MkPrinter q) = MkPrinter (\\(x, y) => Just (++) <$> (p x) <$> (q y))\n\ninstance Invertible.Alternative Printer where\n alt (MkPrinter p) (MkPrinter q) = MkPrinter $ \\s =>\n case (p s) of\n Nothing => (q s)\n x => x\n empty = MkPrinter (\\s => Nothing)\n\ninstance Syntax Printer γ where\n pure x = MkPrinter (\\y =>\n if x == y\n then Just []\n else Nothing)\n token = MkPrinter (\\t => Just [t])\n\n\n-- Invertible.print (times $ (Invertible.pure {α=Bool} {γ=Bool} True)) [True, True]\n-- Invertible.parse (times {n=2} $ (Invertible.pure {α=Bool} {γ=Bool} True)) [True, False, False]\n-- Invertible.print (times $ (Invertible.token {γ=Bool})) [True, False]\n-- Invertible.parse (times {n=3} $ (Invertible.token {γ=Bool})) [True, False, True, False]\n-- Invertible.print (many 2 $ pf (Invertible.token {γ=Bool}) (Invertible.pure {α=Bool} {γ=Bool} True)) [(True, True), (False, True)]\n-- Invertible.parse (many 3 $ pf (Invertible.token {γ=Bool}) (Invertible.pure {α=Bool} {γ=Bool} True)) [True, False]\n", "meta": {"hexsha": "9b189a0e911a36e82da4eb63850e92151845f628", "size": 4091, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "playing-around/Invertible.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/Invertible.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/Invertible.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": 30.7593984962, "max_line_length": 132, "alphanum_fraction": 0.5314104131, "num_tokens": 1369, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677506936879, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.5612892578224774}}
{"text": "module Dataflow\n-- from paper \n-- The Essence of Dataflow Programming. \n-- Tarmo Uustalu and Varmo Vene. 2006\nimport Control.Comonad (Comonad(..))\n\n\nnewtype Id a = Id a\n deriving (Show)\n\ninstance Functor Id where\n fmap f (Id a) = Id $ f a\n \ninstance Applicative Id where\n pure = Id\n Id f <*> Id a = Id $ f a\n \ninstance Monad Id where\n return a = Id a\n Id a >>= k = k a\n\n\n-- Streams and Comonads stuff\ndata Stream a = a :< Stream a\n\ninstance Show a => Show (Stream a) where\n show (a0 :< (a1 :< (a2 :< _))) = show a0 ++ \", \" ++ show a1 ++ \", \" ++ show a2 ++ \",....\"\n\n \nmapS :: (a -> b) -> Stream a -> Stream b\nmapS f (a: Stream b -> Stream (a, b)\nzipS (a: (Stream a, Stream b)\nunzipS pairs = (mapS fst pairs, mapS snd pairs)\n\nnewtype SF a b = SF (Stream a -> Stream b)\n\ninstance Comonad Id where\n extract (Id a) = a\n extend f a = Id $ f a\n\ndata Prod e a = a :& e\n\ninstance Functor (Prod e) where\n fmap f (a :& e) = f a :& e\n \ninstance Comonad (Prod e) where\n extract (a :& _) = a\n extend f pa@(_ :& e) = f pa :& e\n\naskP :: Prod e a -> e\naskP (_ :& e) = e\n\nlocalP :: (e -> e) -> Prod e a -> Prod e a\nlocalP f (a :& e) = a :& f e\n\ninstance Functor Stream where\n fmap f (a :< s) = f a :< fmap f s\n \ninstance Comonad Stream where\n extract (a :< _) = a\n extend f sa@(a :< s) = f sa :< extend f s\n\nnextS :: Stream a ->Stream a\nnextS (_ :< s) = s\n\nnewtype CoKleisli d a b = CoKleisli (d a -> b)\n\npair :: (a -> b) -> (a -> b') -> a -> (b, b')\npair f g x = (f x, g x)\n\n-- instance (Comonad d) => Arrow (CoKleisli d) where\n\nstr2fun :: Stream a -> Int -> a\nstr2fun (a :< _) 0 = a\nstr2fun (_ :< as) i = str2fun as (i-1)\n\nfun2str :: (Int -> a) -> Stream a\nfun2str f = fun2str' f 0\n where\n fun2str' f' i = f' i :< fun2str' f' (i+1)\n\ndata FunArg s a = (s -> a) :# s\n\ninstance Functor (FunArg s) where\n fmap f (sf :# s) = (f . sf) :# s\n \ninstance Comonad (FunArg s) where\n extract (sf :# s) = sf s\n extend f (sf :# s) = (\\s' -> f (sf :# s')) :# s\n \n-- TODO dont really understand this one\nrunFA :: (FunArg Int a -> b) -> Stream a -> Stream b\nrunFA k as = runFA' k (str2fun as :# 0)\n where\n runFA' k' d@(f :# i) = k' d :< runFA' k' (f :# (i + 1))\n\n-- List the other way around\ndata List a = Nil | List a :> a\n deriving (Show)\n-- a non empty list type\ndata LV a = List a := a\n deriving (Show)\n-- past := value :| future\ndata LVS a = LV a :| Stream a\n\ninstance Show a => Show (LVS a) where\n show (az := a :| as) = show az ++ \", \" ++ show a ++ \", \" ++ show as\n \ninstance Functor List where\n fmap f Nil = Nil\n fmap f (as :> a) = fmap f as :> f a\n\ninstance Functor LV where\n fmap f (as := a) = fmap f as := f a\n \ninstance Functor LVS where\n fmap f (az :| as) = fmap f az :| fmap f as\n \ninstance Comonad LVS where\n extract ((_ := a) :| _) = a\n -- List value Stream\n extend k d = cobindL d := k d :| cobindS d\n where\n cobindL (Nil := _ :| _ ) = Nil\n cobindL ((az :> a') := a :| as ) = cobindL d' :> k d'\n where -- see how the a' a have been moved to the right\n d' = az := a' :| (a :< as)\n cobindS (az := a :| (a' :< as')) = k d' :< cobindS d'\n where -- see how the a a' have been moved to the left\n d' = az :> a := a' :| as'\n\nrunLVS :: (LVS a -> b) -> Stream a -> Stream b\nrunLVS k (a' :< as') = runLVS' k (Nil := a' :| as')\n where\n runLVS' k' d@(az := a :| (a'' :< as'')) =\n k' d :< runLVS' k' (az :> a := a'' :| as'')\n\nfbyFA :: a -> (FunArg Int a -> a)\nfbyFA a0 (f :# 0) = a0\nfbyFA _ (f :# i) = f (i-1)\n\nfbyLVS :: a -> (LVS a -> a)\nfbyLVS a0 (Nil := _ :| _) = a0\nfbyLVS _ ((_ :> a') := _ :| _) = a'\n\nnextFA :: FunArg Int a -> a\nnextFA (f :# i) = f (i+1)\n\nnextLVS :: LVS a -> a\nnextLVS (_ := _ :| (a :< _)) = a\n\n\ninstance Comonad LV where\n extract (_ := a) = a\n extend k d@(az := _) = cobindL k az := k d\n where\n cobindL _ Nil = Nil\n cobindL k' (az' :> a) = cobindL k' az' :> k' (az' := a)\n\nfbyLV :: a -> (LV a -> a)\nfbyLV a0 (Nil := _) = a0\nfbyLV _ ((_ :> a) := _) = a\n\n\ntype Var = String\n\ndata Tm = V Var | L Var Tm | Tm :@ Tm -- variables, lambdas, application\n | N Integer | Tm :+ Tm | Tm :- Tm | Tm :* Tm -- numbers and addition and stuff\n | Tm :== Tm | Tm :<= Tm | TT | FF | Not Tm | If Tm Tm Tm -- equality and bool stuff\n | Rec Tm -- recursion\n | Tm `Fby` Tm\n | Next Tm\n deriving (Show)\n \n-- value types will be numbers, bools and functions\ndata Val d = I Integer | B Bool | F (d (Val d) -> Val d)\n\ntype Env d = [(Var, Val d)]\n\nempty :: [(a, b)]\nempty = []\n\n\nzipL :: List a -> List b -> List (a, b)\nzipL Nil _ = Nil\nzipL _ Nil = Nil\nzipL (az :> a) (bz :> b) = (zipL az bz) :> (a, b)\n\nclass Comonad d => ComonadZip d where\n czip :: d a -> d b -> d (a, b)\n\ninstance ComonadZip Id where\n czip (Id a) (Id b) = Id (a, b)\n\ninstance ComonadZip LVS where\n czip (az := a :| as) (bz := b :| bs) =\n zipL az bz := (a, b) :| zipS as bs\n\ninstance ComonadZip LV where\n czip (az := a) (bz := b) = \n zipL az bz := (a, b)\n\nclass ComonadZip d => ComonadEv d where\n ev :: Tm -> d (Env d) -> Val d\n \ninstance ComonadEv Id where\n ev e denv = _ev e denv\n\ninstance ComonadEv LVS where\n ev (Fby e0 e1) denv = ev e0 denv `fbyLVS` extend (ev e1) denv \n ev (Next e) denv = nextLVS (extend (ev e) denv)\n ev e denv = _ev e denv\n\ninstance ComonadEv LV where\n ev (Fby e0 e1) denv = ev e0 denv `fbyLV` extend (ev e1) denv \n ev e denv = _ev e denv\n\nevClosedI :: Tm -> Val Id\nevClosedI e = ev e (Id empty)\n\nemptyL :: Int -> List [(a, b)]\nemptyL 0 = Nil\nemptyL i = emptyL (i-1) :> empty\n\nemptyS :: Stream [(a, b)]\nemptyS = empty :< emptyS\n\nevClosedLVS :: Tm -> Int -> Val LVS\nevClosedLVS e i = ev e (emptyL i := empty :| emptyS)\n\nevClosedLV :: Tm -> Int -> Val LV\nevClosedLV e i = ev e (emptyL i := empty)\n\nupdate :: a -> b -> [(a, b)] -> [(a, b)]\nupdate x y xys = (x, y) : xys\n\nunsafeLookup :: Eq a => a -> [(a, b)] -> b\nunsafeLookup a0 ((a, b):abs) = if a0 == a then b else unsafeLookup a0 abs\n\n_ev :: ComonadEv d => Tm -> d (Env d) -> Val d\n_ev (V x) denv = unsafeLookup x $ extract denv\n_ev (e :@ e') denv = case ev e denv of\n F f -> f (extend (ev e') denv)\n_ev (Rec e) denv = case ev e denv of\n F f -> f (extend (_ev (Rec e)) denv)\n_ev (N n) _ = I n\n_ev (e0 :+ e1) denv = case ev e0 denv of\n I n0 -> case ev e1 denv of\n I n1 -> I (n0 + n1)\n_ev (e0 :- e1) denv = case ev e0 denv of\n I n0 -> case ev e1 denv of\n I n1 -> I (n0 - n1)\n_ev (e0 :* e1) denv = case ev e0 denv of\n I n0 -> case ev e1 denv of\n I n1 -> I (n0 * n1)\n_ev TT _ = B True\n_ev FF _ = B False\n_ev (Not e) denv = case ev e denv of\n B b -> B (not b)\n_ev (e0 :== e1) denv = case ev e0 denv of\n B b0 -> case ev e1 denv of\n B b1 -> B (b0 == b1)\n_ev (e0 :<= e1) denv = case ev e0 denv of\n B b0 -> case ev e1 denv of\n B b1 -> B (b0 <= b1)\n_ev (If e e0 e1) denv = case ev e denv of\n B b -> if b then ev e0 denv else ev e1 denv\n_ev (L x e) denv = F (\\d -> ev e (fmap repair (czip d denv)))\n where\n repair (a, env) = update x a env\n \n-- testing\npos :: Tm\npos = Rec (L \"pos\" (N 0 `Fby` (V \"pos\" :+ N 1)))\n\nposVal :: Stream (Val LVS)\nposVal = runLVS (ev pos) emptyS\n", "meta": {"hexsha": "09c2b024a66953203b75802a7575c9ad7b6d8ead", "size": 7313, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "dataflow.idr", "max_stars_repo_name": "wyn/incremental", "max_stars_repo_head_hexsha": "eee2b612f1f403957fe1793fe8fe04f56c337e4f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2017-05-02T22:33:50.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-26T17:50:38.000Z", "max_issues_repo_path": "dataflow.idr", "max_issues_repo_name": "wyn/incremental", "max_issues_repo_head_hexsha": "eee2b612f1f403957fe1793fe8fe04f56c337e4f", "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": "dataflow.idr", "max_forks_repo_name": "wyn/incremental", "max_forks_repo_head_hexsha": "eee2b612f1f403957fe1793fe8fe04f56c337e4f", "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.9326241135, "max_line_length": 92, "alphanum_fraction": 0.5343908109, "num_tokens": 2889, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.737158174177441, "lm_q1q2_score": 0.5607198463144687}}
{"text": "module Verified.Monad\n\nimport Verified.Applicative\n\n%default total\n\nclass (Monad m, VerifiedApplicative m) => VerifiedMonad (m : Type -> Type) where\n monadApplicative : (mf : m (a -> b)) -> (mx : m a) ->\n mf <*> mx = mf >>= \\f =>\n mx >>= \\x =>\n pure (f x)\n monadLeftIdentity : (x : a) -> (f : a -> m b) -> return x >>= f = f x\n monadRightIdentity : (mx : m a) -> mx >>= return = mx\n monadAssociativity : (mx : m a) -> (f : a -> m b) -> (g : b -> m c) -> \n (mx >>= f) >>= g = mx >>= (\\x => f x >>= g)\n", "meta": {"hexsha": "b79465949b41015bf3f2b554a3289308fe957d35", "size": 617, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Verified/Monad.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/Monad.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/Monad.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": 38.5625, "max_line_length": 80, "alphanum_fraction": 0.4213938412, "num_tokens": 179, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511469672594, "lm_q2_score": 0.6548947223065755, "lm_q1q2_score": 0.5604923992288875}}
{"text": "||| A simply expression language, adapted from PLFA Part 2 [1],\n||| together with mechanical proof of type-safety.\n|||\n||| `PLFA` is an expression language supporting:\n|||\n||| + Let-bindings;\n||| + Products; and\n||| + Sums\n|||\n||| Well-known construction techniques are used to represent the\n||| language as an intrindsically well-typed EDSL, together with it's\n||| mechanical proof of progress.\n|||\n||| This module corresponds to Section 2 of the Functional Pearl.\n|||\n||| [1] https://plfa.github.io/\n|||\nmodule Razor.PLFA\n\nimport Razor.Common\n\n%default total\n\nnamespace Types\n\n public export\n data Ty = TyInt\n | TyChar\n | TyProd Ty Ty\n | TySum Ty Ty\n\nnamespace Terms\n\n public export\n data PLFA : (ctxt : List Ty) -> (type : Ty) -> Type where\n -- Let-Bindings & Variables\n Var : Elem ty g -> PLFA g ty\n Let : (this : PLFA g expr)\n -> (beInThis : PLFA (expr::g) body)\n -> PLFA g body\n\n -- Base Values\n I : Int -> PLFA g TyInt\n C : Char -> PLFA g TyChar\n\n -- Products and accessors\n MkPair : (left : PLFA g l)\n -> (right : PLFA g r)\n -> PLFA g (TyProd l r)\n\n First : (pair : PLFA g (TyProd l r))\n -> PLFA g l\n\n Second : (pair : PLFA g (TyProd l r))\n -> PLFA g r\n\n Split : (pair : PLFA g (TyProd l r))\n -> (body : PLFA (r::l::g) b)\n -> PLFA g b\n\n -- Sums and accessors\n Left : (left : PLFA g l)\n -> PLFA g (TySum l r)\n\n Right : (right : PLFA g r)\n -> PLFA g (TySum l r)\n\n Match : (variant : PLFA g (TySum l r))\n -> (whenLeft : PLFA (l::g) b)\n -> (whenRight : PLFA (r::g) b)\n -> PLFA g b\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 public export\n rename : (forall type . Contains old type -> Contains new type)\n -> (forall type . PLFA old type -> PLFA new type)\n -- Let Bindings & Variables\n rename f (Var x) = Var (f x)\n rename f (Let this beInThis) = 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 -- Products & Accessors\n rename f (MkPair left right) = MkPair (rename f left) (rename f right)\n rename f (First pair) = First (rename f pair)\n rename f (Second pair) = Second (rename f pair)\n rename f (Split pair body) = Split (rename f pair)\n (rename ((weaken (weaken f))) body)\n\n -- Sums & Accessors\n rename f (Left left) = Left (rename f left)\n rename f (Right right) = Right (rename f right)\n rename f (Match variant whenLeft whenRight) = Match (rename f variant)\n (rename (weaken f) whenLeft)\n (rename (weaken f) whenRight)\n\nnamespace Substitution\n\n public export\n weakens : (forall type. Contains old type -> PLFA new type)\n -> (forall type. Contains (old += type') type -> PLFA (new += type') type)\n weakens f Here = Var Here\n weakens f (There rest) = rename There (f rest)\n\n -- general substitute\n namespace General\n public export\n subst : (forall type . Contains old type -> PLFA new type)\n -> (forall type . PLFA old type -> PLFA new type)\n\n -- Let-Bindings & Variables\n subst f (Var x) = (f x)\n subst f (Let this beInThis) = 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 -- Products & Accessors\n subst f (MkPair left right) = MkPair (subst f left) (subst f right)\n subst f (First pair) = First (subst f pair)\n subst f (Second pair) = Second (subst f pair)\n subst f (Split pair body) = Split (subst f pair)\n (subst ((weakens (weakens f))) body)\n\n -- Sums & Accessors\n subst f (Left left) = Left (subst f left)\n subst f (Right right) = Right (subst f right)\n subst f (Match variant whenLeft whenRight) = Match (subst f variant)\n (subst (weakens f) whenLeft)\n (subst (weakens f) whenRight)\n namespace Single\n public export\n apply : (this : PLFA ctxt typeB)\n -> (idx : Contains (ctxt += typeB) typeA)\n -> PLFA ctxt typeA\n apply this Here = this\n apply this (There rest) = Var rest\n\n public export\n subst : (this : PLFA ctxt typeB)\n -> (inThis : PLFA (ctxt += typeB) typeA)\n -> PLFA ctxt typeA\n subst {ctxt} {typeA} {typeB} this inThis = General.subst (apply this) inThis\n\n namespace Double\n\n public export\n apply : (this : PLFA ctxt typeA)\n -> (andThis : PLFA ctxt typeB)\n -> (idx : Contains ((ctxt += typeA) += typeB) typeC)\n -> PLFA ctxt typeC\n apply this andThis Here = andThis\n apply this andThis (There Here) = this\n apply this andThis (There (There x)) = Var x\n\n public export\n subst : (this : PLFA ctxt typeA)\n -> (andThis : PLFA ctxt typeB)\n -> (inThis : PLFA ((ctxt += typeA) += typeB) typeC)\n -> PLFA ctxt typeC\n subst {ctxt} {typeA} {typeB} {typeC} this andThis inThis = General.subst (apply this andThis) inThis\n\n\nnamespace Values\n\n public export\n data Value : PLFA ctxt type -> Type where\n IV : Value (I i)\n CV : Value (C c)\n MkPairV : Value left\n -> Value right\n -> Value (MkPair left right)\n\n LeftV : Value value\n -> Value (Left value)\n\n RightV : Value value\n -> Value (Right value)\n\nnamespace Reduction\n public export\n data Redux : (this, that : PLFA 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 -- MkPairs\n SimplifyPairFirst : Redux this that\n -> Redux (MkPair this right)\n (MkPair that right)\n SimplifyPairSecond : Value left\n -> Redux this that\n -> Redux (MkPair left this)\n (MkPair left that)\n\n -- Accessors\n SimplifyFirst : Redux this that\n -> Redux (First this) (First that)\n\n ReduceFirst : Value left -> Value right -> Redux (First (MkPair left right)) left\n\n SimplifySecond : Redux this that\n -> Redux (Second this) (Second that)\n\n ReduceSecond : Value left -> Value right -> Redux (Second (MkPair left right)) right\n\n -- Split Pairs\n SimplifySplitPair : Redux this that\n -> Redux (Split this body) (Split that body)\n\n ReduceSplitPair : {right : PLFA g r}\n -> {left : PLFA g l}\n -> {body : PLFA (r::l::g) b}\n -> Value left\n -> Value right\n -> Redux (Split (MkPair left right) body)\n (subst left right body)\n\n -- Variants\n SimplifyLeft : Redux this that\n -> Redux (Left this) (Left that)\n\n SimplifyRight : Redux this that\n -> Redux (Right this) (Right that)\n\n SimplifyMatchCase : Redux this that\n -> Redux (Match this whenleft whenright)\n (Match that whenleft whenright)\n\n ReduceMatchBodyWhenLeft : Value value\n -> Redux (Match (Left value) whenleft whenright)\n (subst value whenleft)\n\n ReduceMatchBodyWhenRight : Value value\n -> Redux (Match (Right value) whenleft whenright)\n (subst value whenright)\n\nnamespace Progress\n public export\n data Progress : (term : PLFA Nil type)\n -> Type\n where\n Done : {term : PLFA Nil mty} -> Value term -> Progress term\n Step : {this, that : PLFA Nil type}\n -> (prf : Redux this that)\n -> Progress this\n\n public export\n progress : (term : PLFA Nil type) -> Progress term\n\n -- Let-Bindings & Variables\n progress (Var _) impossible\n progress (Let this beInThis) with (progress this)\n progress (Let this beInThis) | (Done x) = Step (ReduceLetBody x)\n progress (Let this beInThis) | (Step prf) = Step (SimplifyLetValue prf)\n\n -- Base Values\n progress (I x) = Done IV\n progress (C x) = Done CV\n\n -- Products & Accessors\n progress (MkPair left right) with (progress left)\n progress (MkPair left right) | (Done vl) with (progress right)\n progress (MkPair left right) | (Done vl) | (Done vr) = Done (MkPairV vl vr)\n progress (MkPair left right) | (Done vl) | (Step pr) = Step (SimplifyPairSecond vl pr)\n\n progress (MkPair left right) | (Step pl) = Step (SimplifyPairFirst pl)\n\n progress (First pair) with (progress pair)\n progress (First (MkPair left right)) | (Done (MkPairV l r)) = Step (ReduceFirst l r)\n progress (First pair) | (Step pp) = Step (SimplifyFirst pp)\n\n progress (Second pair) with (progress pair)\n progress (Second (MkPair left right)) | (Done (MkPairV l r)) = Step (ReduceSecond l r)\n progress (Second pair) | (Step pp) = Step (SimplifySecond pp)\n\n progress (Split pair body) with (progress pair)\n progress (Split (MkPair left right) body) | (Done (MkPairV l r)) = Step (ReduceSplitPair l r)\n progress (Split pair body) | (Step pp) = Step (SimplifySplitPair pp)\n\n -- Sums & Accessors\n progress (Left left) with (progress left)\n progress (Left left) | (Done lv) = Done (LeftV lv)\n progress (Left left) | (Step lp) = Step (SimplifyLeft lp)\n\n\n progress (Right right) with (progress right)\n progress (Right right) | (Done rv) = Done (RightV rv)\n progress (Right right) | (Step rp) = Step (SimplifyRight rp)\n\n progress (Match variant whenLeft whenRight) with (progress variant)\n progress (Match (Left left) whenLeft whenRight) | (Done (LeftV lv)) = Step (ReduceMatchBodyWhenLeft lv)\n progress (Match (Right right) whenLeft whenRight) | (Done (RightV rv)) = Step (ReduceMatchBodyWhenRight rv)\n progress (Match variant whenLeft whenRight) | (Step vp) = Step (SimplifyMatchCase vp)\n\n\nnamespace Evaluation\n\n public export\n data Reduces : (this : PLFA ctxt type)\n -> (that : PLFA ctxt type)\n -> Type\n where\n Refl : Reduces this this\n Trans : Redux this that\n -> Reduces that end\n -> Reduces this end\n\n public export\n data Finished : (term : PLFA ctxt type)\n -> Type\n where\n Normalised : {term : PLFA ctxt type} -> Value term -> Finished term\n OOF : Finished term\n\n public export\n data Evaluate : (term : PLFA Nil type) -> Type where\n RunEval : (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 : PLFA 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 : PLFA Nil type)\n -> Maybe (Subset (PLFA 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\nnamespace Examples\n public export\n ab : PLFA Nil (TyProd TyInt TyChar)\n ab = MkPair (I 1) (C 'c')\n\n public export\n a : PLFA Nil TyInt\n a = First ab\n\n public export\n b : PLFA Nil TyChar\n b = Second ab\n\n public export\n ba : PLFA Nil (TyProd TyChar TyInt)\n ba = Split ab (MkPair (Var Here) (Var $ There Here))\n\n public export\n l : PLFA Nil (TySum TyChar TyInt)\n l = Left (C 'c')\n\n public export\n r : PLFA Nil (TySum TyChar TyInt)\n r = Right (I 1)\n\n public export\n lp : PLFA Nil (TyProd TyInt TyChar)\n lp = Match l (MkPair (I 2) (Var Here)) (MkPair (Var Here) (C 'w'))\n\n public export\n rp : PLFA Nil (TyProd TyInt TyChar)\n rp = Match r (MkPair (I 2) (Var Here)) (MkPair (Var Here) (C 'w'))\n\n-- snip : PLFA Nil TyInt\n-- snip = Match (Left (I 1)) (Var Here) (Split (Var Here) (Var Here))\n", "meta": {"hexsha": "003e84d3a6a627081b63a60c1c5d83609760940f", "size": 13250, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Razor/PLFA.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/PLFA.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/PLFA.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.042394015, "max_line_length": 111, "alphanum_fraction": 0.5594716981, "num_tokens": 3546, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673087708699, "lm_q2_score": 0.6893056104028799, "lm_q1q2_score": 0.5603139964488507}}
{"text": "\nmodule Normalization\n\n\n\nimport MSubst\nimport PnP\nimport R\nimport Step\nimport Subst\nimport Term\nimport Typing\n\n\n%default total\n\n\n\n----------------------------------------------------------------\n-- Begin: PREDICATE 'Halts' IS PRESERVED UNDER TERM CONSTRUCTION\n\nmSubstHalts_Abs : (e : Term) -> (venv : VEnv ctx) ->\n Halts (msubst (TAbs e) Z venv)\nmSubstHalts_Abs e VNil = H (TAbs e) (TAbs e ** (VAbs, TStRefl _))\nmSubstHalts_Abs e (VCons x _ _ venv) = mSubstHalts_Abs (subst x (S Z) e) venv\n\n\n\nmSubstHalts_Zero : (venv : VEnv ctx) -> Halts (msubst TZero Z venv)\nmSubstHalts_Zero VNil = haltsZero\nmSubstHalts_Zero (VCons _ _ _ venv) = mSubstHalts_Zero venv\n\n\n\nmSubstHalts_Succ : (e : Term) -> (venv : VEnv ctx) ->\n Halts (msubst e Z venv) ->\n Halts (msubst (TSucc e) Z venv)\nmSubstHalts_Succ e venv (H _ (e1 ** (v1, tst))) = \n let tst' = congSucc tst\n eq = mSubstSuccComm e Z venv\n tst'' = replace {P = \\q => TransStep q (TSucc e1)} eq tst'\n in H _ (TSucc e1 ** (VSucc v1, tst''))\n\n\n\nmSubstHalts_Pred : (e : Term) -> Typing ctx e TyNat -> \n (venv : VEnv ctx) ->\n Halts (msubst e Z venv) ->\n Halts (msubst (TPred e) Z venv)\nmSubstHalts_Pred e ty venv (H _ (e1 ** (v1, tst))) = \n let ty' = mSubstPreservesTy e {ctx1=[]} ty venv\n ty'' = transPreservation _ ty' tst\n in case canonicalNat e1 ty'' v1 of\n (Left Refl) => let tst' = congPred tst .+. StPredZero\n eq = mSubstPredComm e Z venv\n in rewrite (sym eq) in H _ (TZero ** (VZero, tst'))\n (Right (_ ** (v1', Refl))) => let st = StPredSucc v1'\n tst' = congPred tst .+. st\n eq = mSubstPredComm e Z venv\n in rewrite (sym eq) in H _ (_ ** (v1', tst'))\n\n-- End: PREDICATE 'Halts' IS PRESERVED UNDER TERM CONSTRUCTION\n--------------------------------------------------------------\n\n\n\n\n--------------------------------------------------------------------\n-- Begin: LOGICAL PREDICATE 'R' IS PRESERVED UNDER TERM CONSTRUCTION\n\nmSubstR_Var : (i : Nat) ->\n (ctx : Context) ->\n index' i ctx = Just t ->\n (venv : VEnv ctx) ->\n r t (msubst (TVar i) Z venv)\nmSubstR_Var Z [] Refl VNil impossible\nmSubstR_Var (S _) [] Refl VNil impossible\nmSubstR_Var Z (s::ctx) Refl (VCons x _ rx venv) = \n let tyx = rTyping x rx\n eq = mSubstPastCtx x [] tyx venv\n in rewrite eq in rx\nmSubstR_Var (S i) (s::ctx) prf (VCons x _ rx venv) = \n mSubstR_Var i ctx prf venv\n\n\n\nmSubstR_App : (e1 : Term) -> (e2 : Term) ->\n (venv : VEnv ctx) ->\n r (s :->: t) (msubst e1 Z venv) ->\n r s (msubst e2 Z venv) ->\n r t (msubst (TApp e1 e2) Z venv)\nmSubstR_App e1 e2 venv r1 r2 = \n let imp = rImplication r1\n r' = imp (msubst e2 Z venv) r2\n in rewrite (sym $ mSubstAppComm e1 e2 Z venv) in r'\n\n\n\nmSubstR_Ifz : (e1 : Term) -> Typing ctx e1 TyNat ->\n (e2 : Term) -> (e3 : Term) -> \n (venv : VEnv ctx) ->\n r TyNat (msubst e1 Z venv) -> \n r t (msubst e2 Z venv) -> \n r t (msubst e3 Z venv) ->\n r t (msubst (TIfz e1 e2 e3) Z venv)\nmSubstR_Ifz e1 ty1 e2 e3 venv r1 r2 r3 =\n let (H _ (e11 ** (v11, tst))) = rHalts r1\n ty11 = mSubstPreservesTy e1 ty1 {ctx1=[]} venv\n ty12 = transPreservation _ ty11 tst\n in case canonicalNat e11 ty12 v11 of\n (Left Refl) => let tst' = congIfz tst \n {ez=(msubst e2 Z venv)} \n {es=(msubst e3 Z venv)}\n .+. StIfzZero\n ty = TyIfz ty11 (rTyping _ r2) (rTyping _ r3)\n r' = transStepPreservesR_2 _ _ ty _ tst' r2\n in rewrite (sym $ mSubstIfzComm e1 e2 e3 Z venv) in r'\n (Right (_ ** (v11', Refl))) => let tst' = congIfz tst \n {ez=(msubst e2 Z venv)} \n {es=(msubst e3 Z venv)}\n .+. StIfzSucc v11'\n ty = TyIfz ty11 (rTyping _ r2) (rTyping _ r3)\n r' = transStepPreservesR_2 _ _ ty _ tst' r3\n in rewrite (sym $ mSubstIfzComm e1 e2 e3 Z venv) in r'\n\n\n\nmSubstR_Rec' : (e1 : Term) -> Value e1 -> Typing [] e1 TyNat -> r TyNat e1 ->\n (e2 : Term) -> (e3 : Term) ->\n (venv : VEnv ctx) ->\n r t (msubst e2 Z venv) -> \n r (TyNat:->:t:->:t) (msubst e3 Z venv) -> \n r t (TRec e1 (msubst e2 Z venv) (msubst e3 Z venv))\n--\nmSubstR_Rec' TZero VZero TyZero r1 e2 e3 venv r2 r3 = \n let st = StRecZero {t0=(msubst e2 Z venv)} {t1=(msubst e3 Z venv)}\n ty = TyRec TyZero (rTyping _ r2) (rTyping _ r3)\n in stepPreservesR_2 _ _ ty _ st r2\n--\nmSubstR_Rec' (TSucc e1) (VSucc v1) (TySucc ty1) r1 e2 e3 venv r2 r3 =\n let r1' = succRR r1\n ih = mSubstR_Rec' e1 v1 ty1 r1' e2 e3 venv r2 r3\n rf = rImplication $ (rImplication r3) _ r1'\n r' = rf _ ih\n --\n st = StRecSucc (VSucc v1) {t0=(msubst e2 Z venv)} {t1=(msubst e3 Z venv)}\n ty = TyRec (TySucc ty1) (rTyping _ r2) (rTyping _ r3)\n in stepPreservesR_2 _ _ ty _ st r'\n--\nmSubstR_Rec' (TAbs e1) VAbs _ r1 e2 e3 venv r2 r3 impossible\n\n\nmSubstR_Rec : (e1 : Term) -> Typing ctx e1 TyNat ->\n (e2 : Term) -> (e3 : Term) ->\n (venv : VEnv ctx) ->\n r TyNat (msubst e1 Z venv) ->\n r t (msubst e2 Z venv) -> \n r (TyNat:->:t:->:t) (msubst e3 Z venv) -> \n r t (msubst (TRec e1 e2 e3) Z venv)\nmSubstR_Rec e1 ty1 e2 e3 venv r1 r2 r3 = \n let (H _ (e11 ** (v11, tst))) = rHalts r1\n tst' = congRec tst {e0=(msubst e2 Z venv)} {e1=(msubst e3 Z venv)}\n ty11 = mSubstPreservesTy e1 ty1 {ctx1=[]} venv\n ty = TyRec ty11 (rTyping _ r2) (rTyping _ r3)\n ty12 = transPreservation _ ty11 tst\n in case canonicalNat e11 ty12 v11 of\n (Left Refl) => let r' = mSubstR_Rec' TZero VZero ty12 rZero e2 e3 venv r2 r3\n r'' = transStepPreservesR_2 _ _ ty _ tst' r'\n in rewrite (sym $ mSubstRecComm e1 e2 e3 Z venv) in r''\n (Right (_ ** (_, Refl))) => let r1' = transStepPreservesR_1 _ _ _ tst r1\n r' = mSubstR_Rec' _ v11 ty12 r1' e2 e3 venv r2 r3\n r'' = transStepPreservesR_2 _ _ ty _ tst' r' \n in rewrite (sym $ mSubstRecComm e1 e2 e3 Z venv) in r''\n\n-- End: LOGICAL PREDICATE 'R' IS PRESERVED UNDER TERM CONSTRUCTION\n------------------------------------------------------------------\n\n\n\n\n--------------------------------------------------\n-- Begin: PREDICATE 'R' HOLDS FOR ALL CLOSED TERMS\n\nmutual\n mSubstR : (e : Term) -> (t : Ty) ->\n Typing ctx e t -> (venv : VEnv ctx) ->\n r t (msubst e Z venv)\n mSubstR e t ty venv = \n let h = mSubstHalts e t ty venv\n ty' = mSubstPreservesTy e {ctx1=[]} ty venv\n in case t of\n TyNat => (ty', h)\n (TyFun t1 t2) => let rf = mSubstR_Fun e t1 t2 ty venv\n in (ty', h, rf)\n\n\n mSubstHalts : (e : Term) -> (t : Ty) ->\n Typing ctx e t -> (venv : VEnv ctx) ->\n Halts (msubst e Z venv)\n --\n mSubstHalts (TVar i) t (TyVar prf) venv = rHalts $ mSubstR_Var _ _ prf venv\n --\n mSubstHalts (TAbs e) (s :->: y) (TyAbs s ty) venv = mSubstHalts_Abs e venv\n --\n mSubstHalts (TApp e1 e2) t (TyApp ty1 ty2) venv =\n let r1 = mSubstR e1 _ ty1 venv\n r2 = mSubstR e2 _ ty2 venv\n in rHalts $ mSubstR_App e1 e2 venv r1 r2\n --\n mSubstHalts (TRec e1 e2 e3) t (TyRec ty1 ty2 ty3) venv =\n let r1 = mSubstR e1 _ ty1 venv\n r2 = mSubstR e2 _ ty2 venv\n r3 = mSubstR e3 _ ty3 venv\n in rHalts $ mSubstR_Rec e1 ty1 e2 e3 venv r1 r2 r3\n --\n mSubstHalts TZero TyNat TyZero venv = mSubstHalts_Zero venv\n --\n mSubstHalts (TSucc e) TyNat (TySucc ty) venv = \n let h = rHalts $ mSubstR e _ ty venv\n in mSubstHalts_Succ e venv h\n --\n mSubstHalts (TPred e) TyNat (TyPred ty) venv =\n let h = rHalts $ mSubstR e _ ty venv\n in mSubstHalts_Pred e ty venv h \n --\n mSubstHalts (TIfz e1 e2 e3) t (TyIfz ty1 ty2 ty3) venv =\n let r1 = mSubstR e1 _ ty1 venv\n r2 = mSubstR e2 _ ty2 venv\n r3 = mSubstR e3 _ ty3 venv\n in rHalts $ mSubstR_Ifz e1 ty1 e2 e3 venv r1 r2 r3\n \n \n mSubstR_Fun : (e : Term) -> (s : Ty) -> (t : Ty) ->\n Typing ctx e (s:->:t) -> (venv : VEnv ctx) ->\n rFun s t (msubst e Z venv)\n --\n mSubstR_Fun (TVar i) s t (TyVar prf) venv y ry = \n let r' = mSubstR_Var _ _ prf venv\n imp = rImplication r'\n in imp y ry\n --\n mSubstR_Fun (TAbs e) s t (TyAbs s ty) venv y ry {ctx} = \n let H _ (y1 ** (vy1, tsty)) = rHalts ry\n ry1 = transStepPreservesR_1 s _ _ tsty ry\n tst1 = congApp2 {e=(TAbs $ msubst e (S Z) venv)} {v=VAbs} tsty\n tst2 = tst1 .+. (StBeta vy1)\n eq1 = mSubstAbsComm e Z venv\n tst3 = replace {P = \\q => TransStep (TApp q y)\n (subst y1 Z (msubst e (S Z) venv))}\n eq1 tst2\n eq2 = mSubstSubstSwap' e Z venv {s=s} y1 vy1 ry1\n tst4 = replace {P = \\q => TransStep (TApp (msubst (TAbs e) Z venv) y) q} \n eq2 tst3\n r' = mSubstR e t ty (VCons y1 vy1 ry1 venv)\n ty' = mSubstPreservesTy {ctx1=[]} (TAbs e) (TyAbs s ty) venv\n ty'' = TyApp ty' (rTyping y ry)\n in transStepPreservesR_2 t _ ty'' _ tst4 r'\n --\n mSubstR_Fun (TApp e1 e2) s t (TyApp ty1 ty2) venv y ry = \n let r1 = mSubstR e1 _ ty1 venv\n r2 = mSubstR e2 _ ty2 venv\n r' = mSubstR_App e1 e2 venv r1 r2\n imp = rImplication r'\n in imp y ry\n --\n mSubstR_Fun (TRec e1 e2 e3) s t (TyRec ty1 ty2 ty3) venv y ry =\n let r1 = mSubstR e1 _ ty1 venv\n r2 = mSubstR e2 _ ty2 venv\n r3 = mSubstR e3 _ ty3 venv\n r' = mSubstR_Rec e1 ty1 e2 e3 venv r1 r2 r3\n imp = rImplication r'\n in imp y ry\n --\n mSubstR_Fun (TIfz e1 e2 e3) s t (TyIfz ty1 ty2 ty3) venv y ry = \n let r1 = mSubstR e1 _ ty1 venv\n r2 = mSubstR e2 _ ty2 venv\n r3 = mSubstR e3 _ ty3 venv\n r' = mSubstR_Ifz e1 ty1 e2 e3 venv r1 r2 r3\n imp = rImplication r'\n in imp y ry\n\n\n\n-- Finally, the fact that 'R' holds for all\n-- closed terms implies that evaluation halts\n-- for all closed terms; i.e. all closed terms\n-- are normalizable: \nhalts : (e : Term) -> Typing [] e t -> Halts e\nhalts e ty = let r = mSubstR e _ ty VNil\n in rHalts r\n\n-- End: PREDICATE 'R' HOLDS FOR ALL CLOSED TERMS\n------------------------------------------------\n", "meta": {"hexsha": "56b079d6a685088ae5b9c531cec641091fbb8522", "size": 11090, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "totality/src/Normalization.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/Normalization.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/Normalization.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": 37.7210884354, "max_line_length": 90, "alphanum_fraction": 0.5087466186, "num_tokens": 4081, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8376199673867852, "lm_q2_score": 0.6688802603710086, "lm_q1q2_score": 0.5602674618776287}}
{"text": "module Search.Negation\n\nimport Data.List.Quantifiers\nimport Data.Nat\n\n%default total\n\n||| It is much easier to look for positive evidence than it is to look\n||| for negative evidence. So instead of looking for `Not q`, we may\n||| want to look for `p` instead\npublic export\ninterface Negates p q | q where\n toNegation : p -> Not q\n\npublic export\n({0 x : a} -> Negates (p x) (q x)) => Negates (All p xs) (Any q xs) where\n toNegation all = allNegAny (mapProperty toNegation all)\n\npublic export\n({0 x : a} -> Negates (p x) (q x)) => Negates (Any p xs) (All q xs) where\n toNegation any = anyNegAll (mapProperty toNegation any)\n\npublic export\nNegates (m `LT` n) (m `GTE` n) where\n toNegation = LTImpliesNotGTE\n\npublic export\nNegates (m `LTE` n) (m `GT` n) where\n toNegation = LTEImpliesNotGT\n", "meta": {"hexsha": "7633c0c85b8dc9a0db46a9afe9d2b855b0879bee", "size": 791, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/contrib/Search/Negation.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": "libs/contrib/Search/Negation.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": "libs/contrib/Search/Negation.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": 26.3666666667, "max_line_length": 73, "alphanum_fraction": 0.6978508217, "num_tokens": 260, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8289387998695209, "lm_q2_score": 0.6757646075489392, "lm_q1q2_score": 0.5601675027759154}}
{"text": "\ndata Expr = Val Int\n | Add Expr Expr\n | Sub Expr Expr\n | Mul Expr Expr\n\nevaluate : Expr -> Int\nevaluate (Val x) = x\nevaluate (Add x y) = evaluate x + evaluate y\nevaluate (Sub x y) = evaluate x - evaluate y\nevaluate (Mul x y) = evaluate x * evaluate y", "meta": {"hexsha": "d2a8c72be1aec2959b3e4a7187ba9230d0e5d0d6", "size": 278, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/ch4/Expr.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/ch4/Expr.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/ch4/Expr.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": 25.2727272727, "max_line_length": 44, "alphanum_fraction": 0.6043165468, "num_tokens": 77, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8840392756357326, "lm_q2_score": 0.6334102705979902, "lm_q1q2_score": 0.5599595567996806}}
{"text": "module Data.Maybe.NothingMax\n\nimport Control.Function\nimport Data.Maybe\nimport Data.Prim.Ord\n\n%default total\n\n||| A total order for `Maybe a` where `a` has a total order\n||| and `Nothing` is the maximal value.\n|||\n||| This is useful, for instance, when implementing provably\n||| sorted (assoc-) lists, indexed by a `Maybe key`, where\n||| the empty list has a `Nothing` index:\n|||\n||| ```idris example\n||| data AssocList : (ix : Maybe Bits8) -> (a : Type) -> Type where\n||| Nil : AssocList Nothing a\n||| (::) : (p : (Bits8, a))\n||| -> (ps : AssocList ix a)\n||| -> (0 prf : LT (<) (Just $ fst p) ix)\n||| => AssocList (Just $ fst p) a\n||| ```\npublic export\ndata LT : (lt : a -> a -> Type) -> (m1,m2 : Maybe a) -> Type where\n LTNothing : LT lt (Just v) Nothing\n LTJust : {0 lt : a -> a -> Type}\n -> {0 v, w : a}\n -> lt v w -> LT lt (Just v) (Just w)\n\npublic export\nUninhabited (LT lt Nothing m) where\n uninhabited LTNothing impossible\n uninhabited (LTJust _) impossible\n\npublic export\nTotal a lt => Uninhabited (LT lt (Just k) (Just k)) where\n uninhabited LTNothing impossible\n uninhabited (LTJust refl) = void (irrefl refl)\n\npublic export\nfromLT : LT lt (Just a) (Just b) -> lt a b\nfromLT (LTJust x) = x\n\n||| Implementation and alias for `trichotomy`.\nexport\ncomp : Total a lt => (m1,m2 : Maybe a) -> Trichotomy (LT lt) m1 m2\ncomp (Just x) (Just y) = case trichotomy {lt} x y of\n LT p c1 c2 => LT (LTJust p) (\\r => c1 (injective r)) (\\x => c2 (fromLT x))\n EQ c1 p c2 => EQ (\\x => c1 (fromLT x)) (cong Just p) (\\x => c2 (fromLT x))\n GT c1 c2 p => GT (\\x => c1 (fromLT x)) (\\r => c2 (injective r)) (LTJust p)\ncomp (Just x) Nothing = LT LTNothing absurd absurd\ncomp Nothing (Just y) = GT absurd absurd LTNothing\ncomp Nothing Nothing = EQ absurd Refl absurd\n\n||| If `lt` is a total order of `a`, then `LT lt` is a\n||| total order of `Maybe a`.\nexport %inline\nTotal a lt => Total (Maybe a) (LT lt) where\n trichotomy = comp\n\n transLT (LTJust x) LTNothing = LTNothing\n transLT (LTJust x) (LTJust y) = LTJust $ trans x y\n transLT LTNothing y = absurd y\n", "meta": {"hexsha": "ff08556bf49f387e63b02c05a98cc83c1f4c6511", "size": 2123, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Maybe/NothingMax.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/Maybe/NothingMax.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/Maybe/NothingMax.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": 32.6615384615, "max_line_length": 76, "alphanum_fraction": 0.6146961846, "num_tokens": 715, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637361282707, "lm_q2_score": 0.6513548646660543, "lm_q1q2_score": 0.5599461565041444}}
{"text": "module Hezarfen.Definitions\n\n%access public export\n\n||| Simply-typed eliminator for `Dec`\ndec : {a, c : Type} -> Lazy (a -> c) -> Lazy ((a -> Void) -> c) -> Dec a -> c\ndec f _ (Yes prf) = f prf\ndec _ g (No contra) = g contra\n", "meta": {"hexsha": "714afc846ac082000595be7a48d0d21ee59a621d", "size": 225, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Hezarfen/Definitions.idr", "max_stars_repo_name": "joom/hezarfen", "max_stars_repo_head_hexsha": "da80a475cf57dee5cd3c10452878d951f1fa490f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 121, "max_stars_repo_stars_event_min_datetime": "2017-10-09T02:58:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-23T21:34:51.000Z", "max_issues_repo_path": "Hezarfen/Definitions.idr", "max_issues_repo_name": "joom/hezarfen", "max_issues_repo_head_hexsha": "da80a475cf57dee5cd3c10452878d951f1fa490f", "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": "Hezarfen/Definitions.idr", "max_forks_repo_name": "joom/hezarfen", "max_forks_repo_head_hexsha": "da80a475cf57dee5cd3c10452878d951f1fa490f", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 5, "max_forks_repo_forks_event_min_datetime": "2017-10-10T19:49:26.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-10T14:55:33.000Z", "avg_line_length": 25.0, "max_line_length": 77, "alphanum_fraction": 0.6, "num_tokens": 80, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7931059609645724, "lm_q2_score": 0.7057850340255386, "lm_q1q2_score": 0.5597623176452382}}
{"text": "data Tree a = Empty\n | Node (Tree a) a (Tree a)\n\nEq a => Eq (Tree a) where\n (==) Empty Empty = True\n (==) (Node l e r) (Node l' e' r')\n = l == l' && e == e' && r == r'\n (==) _ _ = False\n\nFoldable Tree where\n foldr func acc Empty = acc\n foldr func acc (Node l e r) =\n let left = foldr func acc l\n right = foldr func left r in\n func e right\n", "meta": {"hexsha": "09379533ea86c48566d307655f69c8e3d4062f64", "size": 383, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Chapter-07/tree.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/tree.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/tree.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": 23.9375, "max_line_length": 38, "alphanum_fraction": 0.501305483, "num_tokens": 131, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8198933359135361, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.5596376455258912}}
{"text": "module Syntax\n\n||| Types\npublic export\ndata Ty : Type where\n ||| Integers\n TInt : Ty\n ||| Booleans\n TBool : Ty\n ||| Functions\n TArrow : Ty -> Ty -> Ty\n\nexport\nimplementation Eq Ty where\n TInt == TInt = True\n TBool == TBool = True\n (TArrow p1 r1) == (TArrow p2 r2) = p1 == p2 && r1 == r2\n _ == _ = False\n\nexport\nimplementation Show Ty where\n show TInt = \"int\"\n show TBool = \"bool\"\n show (TArrow pty rty) = \"(\" ++ (show pty) ++ \" → \" ++ (show rty) ++ \")\"\n\npublic export\nName : Type\nName = String\n\npublic export\ndata Expr : Type where\n ||| Variables\n Var : Name -> Expr\n ||| Non-negative \"integer\" constant\n EInt : Integer -> Expr\n ||| Boolean constant\n EBool : Bool -> Expr\n ||| Product `e1 * e2`\n Times : Expr -> Expr -> Expr\n ||| Sum `e1 + e2`\n Plus : Expr -> Expr -> Expr\n ||| Difference `e1 - e2`\n Minus : Expr -> Expr -> Expr\n ||| Int comparison `e1 = e2`\n Equal : Expr -> Expr -> Expr\n ||| Int comparison `e1 < e2`\n Less : Expr -> Expr -> Expr\n ||| Conditional `if e1 then e2 else e3`\n If : Expr -> Expr -> Expr -> Expr\n ||| Function `fun f(x:s):t is e`\n Fun : Name -> Name -> Ty -> Ty -> Expr -> Expr\n ||| Application `e1 e2`\n Apply : Expr -> Expr -> Expr\n\nexport\nimplementation Show Expr where\n show (Var name) = \"(Var \" ++ name ++ \")\"\n show (EInt n) = show n\n show (EBool b) = show b\n show (Times e1 e2) = \"(\" ++ show e1 ++ \" * \" ++ show e2 ++ \")\"\n show (Plus e1 e2) = \"(\" ++ show e1 ++ \" + \" ++ show e2 ++ \")\"\n show (Minus e1 e2) = \"(\" ++ show e1 ++ \" - \" ++ show e2 ++ \")\"\n show (Equal e1 e2) = \"(\" ++ show e1 ++ \" = \" ++ show e2 ++ \")\"\n show (Less e1 e2) = \"(\" ++ show e1 ++ \" < \" ++ show e2 ++ \")\"\n show (If c te fe) = \"if\" ++ show c ++ \" then \" ++ show te ++ \" else \" ++ show fe\n show (Fun fnm pnm pty rty body) = \"fun \" ++ show fnm ++ \" (\" ++ pnm ++ \" : \" ++ show pty ++ \") : \" ++ show (rty) ++ \" is \" ++ (show body)\n show (Apply e1 e2) = \"(\" ++ show e1 ++ \" \" ++ show e2 ++ \")\"\n\npublic export\ndata TopLevelCmd : Type where\n ||| Expression\n TopExpr : Expr -> TopLevelCmd\n ||| Value definition `let x = e`\n TopDef : Name -> Expr -> TopLevelCmd\n", "meta": {"hexsha": "08d5a14ca3aa08057c310b175d9f12f54355407d", "size": 2158, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Syntax.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/Syntax.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/Syntax.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": 28.7733333333, "max_line_length": 139, "alphanum_fraction": 0.5203892493, "num_tokens": 742, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737869342623, "lm_q2_score": 0.695958331339634, "lm_q1q2_score": 0.5589754885305039}}
{"text": "import Data.Vect\n\nfour_eq : 4 = 4\nfour_eq = Refl\n\n-- four_eq_five : 4 = 5\n-- four_eq_five = Refl\n\ntwoplustwo_eq_four : 2 + 2 = 4\ntwoplustwo_eq_four = Refl\n\nplus_reduces_Z : (m : Nat) -> plus Z m = m\nplus_reduces_Z m = Refl\n\nplus_reduces_Sk : (k, m : Nat) -> plus (S k) m = S (plus k m)\nplus_reduces_Sk k m = Refl\n\nidris_not_php : Z = \"Z\"\n\nvect_eq_length : (xs : Vect n a) -> (ys : Vect m a) -> (xs = ys) -> n = m\nvect_eq_length xs xs Refl = Refl\n", "meta": {"hexsha": "b9d13d96a4ea8952f00b6e564900e6362a0b11a6", "size": 446, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/samples/proofs/prfintro.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/samples/proofs/prfintro.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/samples/proofs/prfintro.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": 20.2727272727, "max_line_length": 73, "alphanum_fraction": 0.634529148, "num_tokens": 184, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7490872243177517, "lm_q2_score": 0.7461389930307512, "lm_q1q2_score": 0.5589231872446476}}
{"text": "module Data.Strong.Array.Interfaces\n\nimport Data.Strong.Array\nimport public Numeric.Floating\n\n-- Separated interfaces due to needing `{s:_} ->` everywhere\n\nexport\n{s:_} -> Num a => Num (Array s a) where\n (+) = Array.(+)\n (*) = Array.(*)\n fromInteger = Array.fromInteger\n\nexport\n{s:_} -> FromDouble a => FromDouble (Array s a) where\n fromDouble = Array.fromDouble\n\nexport\n{s:_} -> Neg a => Neg (Array s a) where\n (-) = Array.(-)\n negate = Array.negate\n\nexport\n{s:_} -> Abs a => Abs (Array s a) where\n abs = Array.abs\n\nexport\n{s:_} -> Fractional a => Fractional (Array s a) where\n (/) = Array.(/)\n recip x = 1 / x -- Get a weird error if I don't supply this myself\n\nexport\n{s:_} -> Integral a => Integral (Array s a) where\n div = Array.div\n mod = Array.mod\n\nexport\n{s:_} -> Floating a => Floating (Array s a) where\n pi = Array.pi\n euler = Array.euler\n exp = Array.exp\n log = Array.log\n pow = Array.pow\n sin = Array.sin\n cos = Array.cos\n tan = Array.tan\n asin = Array.asin\n acos = Array.acos\n atan = Array.atan\n sinh = Array.sinh\n cosh = Array.cosh\n tanh = Array.tanh\n sqrt = Array.sqrt\n", "meta": {"hexsha": "30a198f95cda31dc45e29b1600ebd95469f16482", "size": 1110, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Strong/Array/Interfaces.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/Data/Strong/Array/Interfaces.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/Data/Strong/Array/Interfaces.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": 20.5555555556, "max_line_length": 68, "alphanum_fraction": 0.6369369369, "num_tokens": 349, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8723473779969194, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.5588569962498102}}
{"text": "import Data.Primitives.Views\nimport ArithInputs\n\nquiz : Stream Int -> (score : Nat) -> IO ()\nquiz (num1 :: num2 :: nums) score\n = do putStrLn (\"Score: \" ++ show score)\n putStr (show num1 ++ \" * \" ++ show num2 ++ \" \")\n answer <- getLine\n if (cast answer == num1 * num2)\n then do putStrLn \"Correct!\"\n quiz nums (score + 1)\n else do putStrLn (\"Wrong, the answer is \" ++ show (num1 * num2))\n quiz nums score\n", "meta": {"hexsha": "1316d392961c91558507e7c297f43cca154279b8", "size": 463, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Chapter-11/arith_partial.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-11/arith_partial.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-11/arith_partial.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": 33.0714285714, "max_line_length": 71, "alphanum_fraction": 0.5507559395, "num_tokens": 125, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9196425223682086, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.5588328902553816}}
{"text": "> module Fun.Operations\n\n\n> %default total\n> %access public export\n> %auto_implicits on\n\n\n> |||\n> pair : (a -> b, a -> c) -> a -> (b, c)\n> pair (f, g) x = (f x, g x)\n\n\n> |||\n> cross : (a -> c) -> (b -> d) -> (a, b) -> (c, d)\n> cross f g (x, y) = (f x, g y)\n\n\n> |||\n> modifyFun : {a : Type} -> {b : Type} -> (Eq a) =>\n> (a -> b) -> a -> b -> (a -> b)\n> modifyFun f a b a' = if a' == a then b else f a'\n", "meta": {"hexsha": "f459581a2c3062f1b00419b8797f0a6f2a5ef09a", "size": 413, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "Fun/Operations.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": "Fun/Operations.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": "Fun/Operations.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": 17.9565217391, "max_line_length": 51, "alphanum_fraction": 0.4092009685, "num_tokens": 171, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7549149758396752, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.5587687063090572}}
{"text": "module Lines\r\n\r\nimport Data.Fin\r\nimport Data.Vect\r\n\r\nimport SizedStrings\r\nimport MaybeFin\r\n\r\n%default total\r\n%access public\r\n\r\ndata Lines : Vect k Nat -> Type where\r\n Nil : Lines []\r\n (::) : SizedString n -> Lines v -> Lines (n :: v)\r\n\r\n%name Lines linez -- so as to avoid confusion with lines function\r\n\r\nindex : {v : Vect k Nat} -> (i : Fin k) -> Lines v -> SizedString (index i v)\r\nindex FZ (x :: xs) = x\r\nindex (FS y) (x :: xs) = index y xs\r\n\r\nreplaceAt : { size : Vect (S k) Nat } ->\r\n (i : Fin (S k)) ->\r\n SizedString (index i size) -> \r\n Lines size ->\r\n Lines size\r\nreplaceAt FZ str (x::xs) = str :: xs\r\nreplaceAt (FS i) str (x::[]) = absurd i\r\nreplaceAt (FS i) str (x::(y :: z)) = x :: replaceAt i str (y :: z)\r\n\r\nreplaceAndResizeAt : { size : Vect (S k) Nat } ->\r\n (i : Fin (S k)) ->\r\n SizedString n -> \r\n Lines size ->\r\n Lines (replaceAt i n size)\r\nreplaceAndResizeAt FZ str (x::xs) = str :: xs\r\nreplaceAndResizeAt (FS i) str (x::[]) = absurd i\r\nreplaceAndResizeAt (FS i) str (x::(y :: z)) = x :: replaceAndResizeAt i str (y :: z)\r\n\r\nline_length_equals_size_from_type : {v : Vect k Nat} -> (i : Fin k) -> (ll : Lines v) -> \r\n length (index i ll) = index i v\r\nline_length_equals_size_from_type FZ [] impossible\r\nline_length_equals_size_from_type (FS _) [] impossible\r\nline_length_equals_size_from_type FZ (_ :: _) = Refl\r\nline_length_equals_size_from_type (FS _) (_ :: _) = Refl\r\n\r\nvectSizeVector : Vect k String -> Vect k Nat\r\nvectSizeVector = map length\r\n\r\nreadFromVect : (v : Vect k String) -> Lines (vectSizeVector v)\r\nreadFromVect [] = []\r\nreadFromVect (x :: xs) = sizeString x :: readFromVect xs\r\n\r\nlistSizeVector : (xs : List String) -> Vect (length xs) Nat\r\nlistSizeVector xs = vectSizeVector $ fromList xs\r\n\r\nreadFromList : (xs : List String) -> Lines (listSizeVector xs)\r\nreadFromList xs = readFromVect $ fromList xs\r\n\r\nwriteLinesToList : Lines v -> List String\r\nwriteLinesToList [] = []\r\nwriteLinesToList (l :: ls) = cast l :: writeLinesToList ls\r\n\r\ndeleteLine : {v : Vect (S k) Nat} -> (i : Fin (S k)) -> Lines v -> Lines (deleteAt i v)\r\ndeleteLine FZ (str :: strs) = strs\r\ndeleteLine {k = Z} (FS i) _ = absurd i\r\ndeleteLine {k = S j} (FS i) (str :: strs) = str :: deleteLine i strs\r\n\r\ninsertLine : {v : Vect k Nat} -> (i : Fin (S k)) -> (s: SizedString n) -> Lines v ->\r\n Lines (insertAt i n v)\r\ninsertLine FZ s ls = s :: ls\r\ninsertLine (FS y) s [] = absurd y\r\ninsertLine (FS y) s (str :: ls) = str :: insertLine y s ls\r\n\r\nreplaceChar : {size : Vect (S k) Nat} ->\r\n (row : Fin (S k)) ->\r\n (column : MaybeFin (index row size)) ->\r\n Char ->\r\n Lines size ->\r\n Lines size\r\nreplaceChar row column c linez =\r\n replaceAt row (maybeReplaceAt column c $ index row linez) linez\r\n\r\nInsertAfterType : (size : Vect (S k) Nat) ->\r\n (row : Fin (S k)) ->\r\n Nat ->\r\n Type\r\nInsertAfterType size row textLength =\r\n Lines $ replaceAt row (index row size + textLength) size\r\n\r\ninsertAfter : {size : Vect (S k) Nat} ->\r\n (row : Fin (S k)) ->\r\n (column : MaybeFin (index row size)) ->\r\n SizedString l ->\r\n Lines size ->\r\n InsertAfterType size row l\r\ninsertAfter row column str linez =\r\n replaceAndResizeAt row (insertAfter (index row linez) column str) linez\r\n\r\nInsertBeforeType : (size : Vect (S k) Nat) ->\r\n (row : Fin (S k)) ->\r\n Nat ->\r\n Type\r\nInsertBeforeType size row textLength =\r\n Lines $ replaceAt row (textLength + index row size) size\r\n\r\ninsertBefore : {size : Vect (S k) Nat} ->\r\n (row : Fin (S k)) ->\r\n (column : MaybeFin (index row size)) ->\r\n SizedString l ->\r\n Lines size ->\r\n InsertBeforeType size row l\r\ninsertBefore row column str linez =\r\n replaceAndResizeAt row (insertBefore (index row linez) column str) linez\r\n\r\nDeleteCharType : (size : Vect (S k) Nat) ->\r\n (row : Fin (S k)) ->\r\n Type\r\nDeleteCharType size row = Lines $ replaceAt row (Nat.pred $ index row size) size\r\n\r\ndeleteChar : {size : Vect (S k) Nat} ->\r\n (row : Fin (S k)) ->\r\n (column : MaybeFin (index row size)) ->\r\n Lines size ->\r\n DeleteCharType size row\r\ndeleteChar row column linez = \r\n replaceAndResizeAt row (deleteAt column $ index row linez) linez\r\n\r\ncharAt : {size : Vect (S k) Nat} ->\r\n (row : Fin (S k)) ->\r\n (column : MaybeFin (index row size)) ->\r\n Lines size ->\r\n Maybe Char\r\ncharAt row column linez =\r\n maybeStrIndex (index row linez) column\r\n\r\n", "meta": {"hexsha": "fa0aa6c4e6098e087fb66657f7e3ee92c06b81e3", "size": 4830, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Lines.idr", "max_stars_repo_name": "PolyglotSymposium/void.idr", "max_stars_repo_head_hexsha": "bdea1aeea6758928d79c47cefc0ac94bb1a7de1e", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-12-01T03:17:12.000Z", "max_stars_repo_stars_event_max_datetime": "2015-12-01T03:17:12.000Z", "max_issues_repo_path": "src/Lines.idr", "max_issues_repo_name": "PolyglotSymposium/void.idr", "max_issues_repo_head_hexsha": "bdea1aeea6758928d79c47cefc0ac94bb1a7de1e", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2016-01-15T02:36:00.000Z", "max_issues_repo_issues_event_max_datetime": "2016-01-15T18:52:24.000Z", "max_forks_repo_path": "src/Lines.idr", "max_forks_repo_name": "PolyglotSymposium/void.idr", "max_forks_repo_head_hexsha": "bdea1aeea6758928d79c47cefc0ac94bb1a7de1e", "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": 35.2554744526, "max_line_length": 90, "alphanum_fraction": 0.5596273292, "num_tokens": 1333, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879312155622449, "lm_q2_score": 0.7090191214879991, "lm_q1q2_score": 0.5586582982509141}}
{"text": "append : Vect n a -> Vect m a -> \n Vect (n + m) a\n\nappend [] ys = ys\nappend (x :: xs) ys = x :: append xs ys \n", "meta": {"hexsha": "28e025e86502500bb4475351bbdecd83152c7754", "size": 118, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "proposal/code/vectAppend.idr", "max_stars_repo_name": "RossMeikleham/MSci-Project", "max_stars_repo_head_hexsha": "4e1e3e08bf8440add18b4a87b96ca42920336e14", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-10-20T11:17:45.000Z", "max_stars_repo_stars_event_max_datetime": "2015-10-20T11:17:45.000Z", "max_issues_repo_path": "proposal/code/vectAppend.idr", "max_issues_repo_name": "RossMeikleham/MSci-Project", "max_issues_repo_head_hexsha": "4e1e3e08bf8440add18b4a87b96ca42920336e14", "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": "proposal/code/vectAppend.idr", "max_forks_repo_name": "RossMeikleham/MSci-Project", "max_forks_repo_head_hexsha": "4e1e3e08bf8440add18b4a87b96ca42920336e14", "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": 19.6666666667, "max_line_length": 40, "alphanum_fraction": 0.4830508475, "num_tokens": 40, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7879311856832191, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.5586582916000093}}
{"text": "-- ------------------------------------------------------ [ GettingStarted.idr ]\n-- Module : Exercises.GettingStarted\n-- Description : Solutions to the Chapter 2 exercises in Edwin Brady's\n-- book, \"Type-Driven Development with Idris.\"\n-- --------------------------------------------------------------------- [ EOH ]\nmodule Exercises.GettingStarted\n\n%access export\n\n-- ----------------------------------------------------------- [ 2.5 Exercises ]\n\nexercise1_1 : (String, String, String)\nexercise1_1 = (\"A\", \"B\", \"C\")\n\nexercise1_2 : List String\nexercise1_2 = [\"A\", \"B\", \"C\"]\n\nexercise1_3 : ((Char, String), Char)\nexercise1_3 = (('A', \"B\"), 'C')\n\nnamespace Simple\n\n ||| Determine whether a string reads the same backwards as forwards.\n ||| @ str a string to analyze\n palindrome : (str : String) -> Bool\n palindrome str = str == reverse str\n\nnamespace CaseInsensitive\n\n ||| Determine, case insensitively, whether a string reads the same backwards\n ||| as forwards.\n ||| @ str a string to analyze\n palindrome : (str : String) -> Bool\n palindrome = Simple.palindrome . toLower\n\nnamespace LongerThanN\n\n ||| Return `True` iff `str` is longer than `len` characters and\n ||| case-insensitively reads the same backwards as forwards.\n ||| @ len the lower bound (exclusive) of string length\n ||| @ str a string to analyze\n palindrome : (len : Nat) -> (str : String) -> Bool\n palindrome n str = length str > n && CaseInsensitive.palindrome str\n\nnamespace LongerThan10\n\n ||| Return `True` iff `str` is longer than 10 characts and case-insensitively\n ||| reads the same backwards as forwards.\n ||| @ str a string to analyze\n palindrome : (str : String) -> Bool\n palindrome = LongerThanN.palindrome 10\n\n||| Compute the number of words and number of characters in a string.\n||| @ str a string to analyze\ncounts : (str : String) -> (Nat, Nat)\ncounts str =\n let wordCount = length (words str)\n charCount = length str\n in (wordCount, charCount)\n\n||| Return the largest ten values in a list.\n||| @ list a list of values contstrained by `Ord`\ntopTen : Ord a => (list : List a) -> List a\ntopTen = take 10 . sortBy (flip compare)\n\n-- NOTE: This is a bit like Clojure's cond->.\nsyntax \"cond$\" [x] [b] [f] = if b then x else f x\n\n||| Count the number of strings in list that are over a given length.\n||| @ len the lower bound (exclusive) of string length\noverLength : (len : Nat) -> List String -> Nat\noverLength len = foldr go 0\n where\n go : String -> Nat -> Nat\n go str n = cond$ n (length str > len) S\n\n-- --------------------------------------------------------------------- [ EOF ]\n", "meta": {"hexsha": "0948d2d300ddbbbc7c02f270919828fc32d1a120", "size": 2615, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Exercises/GettingStarted.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/GettingStarted.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/GettingStarted.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": 33.5256410256, "max_line_length": 80, "alphanum_fraction": 0.6038240918, "num_tokens": 672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.7371581510799252, "lm_q1q2_score": 0.5586142976275884}}
{"text": "module Graph\n\nimport Data.List\nimport Data.List.Quantifiers\n\n-- Notes on a theory of graphs\n-- Greg Meredith\n-- https://stackedit.io/editor#!provider=couchdb&id=UdUSSGCZgNDxSIPYmMfoX5Kk\n\n%default total\n\nDisjoint : (xs, ys : List a) -> Type\nDisjoint xs ys = All (\\y => Not (Elem y xs)) ys\n\n-- TODO: nicer syntax; maybe even dsl block\n-- ISSUE: x, v have to be Dec\n\nsyntax GG \"[\" [x] \",\" [v] \"]\" \";\" [gamma] \"|-\" [g] = WellFormed x v gamma g;\nsyntax G \"[\" [x] \",\" [v] \"]\" = GraphExpression x v;\n\ndata GraphExpression : (x: Type) -> (v: Type) -> Type where\n Empty : G[x, v]\n Adjoin : v -> G[x, v] -> G[x, v]\n AdjoinX : x -> G[x, v] -> G[x, v]\n Juxtapose : G[x, v] -> G[x, v] -> G[x, v]\n Let : x -> v -> G[x, v] -> G[x, v]\n Connect : x -> v -> G[x, v] -> x -> v -> G[x, v] -> G[x, v]\n\nsyntax [v] \":|\" [g] = Adjoin v g;\nsyntax [x] \":/\" [g] = AdjoinX x g; -- hmm..\nsyntax [g1] \":*:\" [g2] = Juxtapose g1 g2;\nsyntax \"let\" [x] \"=\" [v] \"in\" [g] = Let x v g;\nsyntax \"{\" \"let\" [x1] \"=\" [v1] \"in\" [g1] \",\" \"let\" [x2] \"=\" [v2] \"in\" [g2] \"}\" = Connect x1 v1 g1 x2 v2 g2;\n\nsyntax GV \"[\" [x] \",\" [v] \"]\" \";\" [gamma] \"|-\" [v'] = AdmissibleVertex x v gamma v';\n\ndata AdmissibleVertex : (x, v: Type) -> (List x) -> v -> Type where\n Verticity : {v': v} -> (GV[x, v] ; [] |- v')\n\n\nsyntax GX \"[\" [xx] \",\" [vv] \"]\" \";\" [gamma] \"|-\" [x] = AdmissibleVariable xx vv gamma x;\n\ndata AdmissibleVariable : (x, v: Type) -> (List x) -> x -> Type where\n -- what is \\emptyset doing in Variation? Why not ()?\n Variation : {x': x} -> (GX[x, v] ; [] |- x')\n\ndata WellFormed : (x, v: Type) -> (List x) -> G[x, v] -> Type where\n Foundation : GG[x, v] ; [] |- Empty\n Participation : (GG[x, v] ; gamma |- g) -> (GV[x, v] ; [] |- v')\n -> GG[x, v] ; gamma |- (v' :| g)\n Dependence :(GG[x, v] ; gamma |- g) -> (GX[x, v] ; [] |- x')\n -> GG[x, v] ; gamma |- (x' :/ g)\n Juxtaposition : {auto disjoint: Disjoint gamma1 gamma2 }\n -> (GG[x, v]; gamma1 |- g1) -> (GG[x, v]; gamma2 |- g2)\n -> GG[x, v]; (gamma1 ++ gamma2) |- (g1 :*: g2)\n Nomination :\n (GG[x, v]; (x' :: gamma) |- g) -> (GV[x, v]; [] |- v')\n -> GG[x, v]; gamma |- (let x' = v' in g)\n Connection : {auto disjoint: Disjoint gamma1 gamma2 }\n -> (GG[x, v]; gamma1 |- (let x1 = v1 in g1))\n -> (GG[x, v]; gamma2 |- (let x2 = v2 in g2))\n -> (GG[x, v]; (gamma1 ++ gamma2) |- ({let x1 = v1 in g1, let x2 = v2 in g2}))\n\nsyntax GE \"[\" [x] \",\" [v] \"]\" \"|-\" [v'] \"in\" [g] = Membership x v v' g;\n\ndata Membership: (x, v: Type) -> (v': v) -> G[x, v] -> Type where\n Ground: GE[x, v] |- v' in (v' :| g)\n Union: (GE[x, v] |- v' in g)\n -> GE[x, v] |- v' in (g :*: g')\n Transparency: (GE[x, v] |- v' in g)\n -> GE[x, v] |- v' in (let x' = v' in g)\n Link_L: (GE[x, v] |- v' in g_1)\n -> GE[x, v] |- v' in ({let x_1 = v_1 in g_1, let x_2 = v_2 in g_2})\n Link_R: (GE[x, v] |- v' in g_2)\n -> GE[x, v] |- v' in ({let x_1 = v_1 in g_1, let x_2 = v_2 in g_2})\n\n\n-- hmm... can we absorb, rather than reify, some of these |-s?\nsyntax GI \"[\" [x] \",\" [v] \"]\" \"|-\" [g1] \"=\" [g2] = Equiv x v g1 g2\n\ndata Equiv: (x, v: Type) -> G[x, v] -> G[x, v] -> Type where\n Identity: GI[x, v] |- (Empty :*: g) = g\n Symmetry: GI[x, v] |- (g1 :*: g2) = (g2 :*: g1)\n Associativity: GI[x, v] |- (g1 :*: (g2 :*: g3)) = ((g1 :*: g2) :*: g3)\n Permutation: GI[x, v] |- (v1 :| (vi :| (vj :| g))) = (v1 :| (vj :| (vi :| g)))\n Conservation: GI[x, v] |- (Let xx vv (Let x' vv g)) = (Let xx vv g)\n{- Issue: variables / terms\n Extrusion: (Not (GE[x, v] |- xx in g2))\n -> GI[x, v] |- ((Let xx vv g1) :*: g2) = (Let xx vv (g1 :*: g2))\n-}\n\ndiscrete : Nat -> G[x, Nat]\ndiscrete Z = Empty\ndiscrete (S n_1) = (n :| Empty) :*: (discrete n_1)\n where n = S n_1\n\nconnect' : G[x, v] -> G[x, v] -> G[x, v]\nconnect' (let x1 = v1 in g1) (let x2 = v2 in g2) = {let x1 = v1 in g1, let x2 = v2 in g2}\nconnect' _ _ = Empty\n\nchain : Nat -> G[Nat, Nat]\nchain Z = Empty\nchain (S Z) = Let 2 1 (1 :| Empty)\nchain (S n_1) =\n Let (2 * n) n (connect' (let ((2 * (S n_1)) - 1) = n in (n :| Empty))\n (chain n_1))\n where n = S n_1\n\ncycle : Nat -> G[Nat, Nat]\ncycle Z = Empty\ncycle (S k) = connect' (chain n) (chain 1)\n where\n n = (S k)\n\nvertices : Eq v => G[x, v] -> List v\nvertices Empty = []\nvertices (v :| g) = union [v] (vertices g)\nvertices (x :/ g) = vertices g\nvertices (g1 :*: g2) = union (vertices g1) (vertices g2)\nvertices (let x = v in g) = vertices g -- ISSUE: is this right?\nvertices ({let x1 = v1 in g1, let x2 = v2 in g2}) = union (vertices g1) (vertices g2)\n\nedges : Eq v => G[x, v] -> List (v, v)\nedges Empty = []\nedges (v :| g) = edges g\nedges (x :/ g) = edges g\nedges (g1 :*: g2) = union (edges g1) (edges g2)\nedges (let x = v in g) = edges g -- ISSUE: is this right?\nedges ({let x1 = v1 in g1, let x2 = v2 in g2}) = union [(v1, v2)] (union (edges g1) (edges g2))\n\n\ncomplete: Nat -> G[Nat, Nat]\ncomplete Z = Empty\n-- EDIT: paper says (discrete 1)\ncomplete (S n_1) = combineAll (discrete n) (complete n_1)\n where\n n = S n_1\n combineAll : G[Nat, Nat] -> G[Nat, Nat] -> G[Nat, Nat]\n combineAll g1 g2 = foldr Juxtapose (g1 :*: g2) [\n {let x1 = x in g1, let x2 = y in g2}\n | x <- (vertices g1), y <- (vertices g2)]\n where\n -- ISSUE: where do x1, x2 come from?\n x1 = 1\n x2 = 2\n\n-- Graph references\n\nsyntax GA \"[\" [x] \",\" [v] \"]\" \";\" [gamma] \";\" [bigG] \"|-\" [a] = WFGraphRef x v gamma bigG a;\n\ndata WFGraphRef: (Either xv xg) -> v -> (List xv) -> (List xg) -> (a: xg) -> Type where\n Wire: GA[x, v] ; gamma ; [a] |- a\n\ngmap : (x -> x') -> G[x, v] -> G[x', v]\ngmap f Empty = Empty\ngmap f (v :| g) = v :| (gmap f g)\ngmap f (x :/ g) = (f x) :/ (gmap f g)\ngmap f (g1 :*: g2) = (gmap f g1) :*: (gmap f g2)\ngmap f (Let x v g) = Let (f x) v (gmap f g)\ngmap f ({let x1 = v1 in g1, let x2 = v2 in g2}) =\n ({let (f x1) = v1 in (gmap f g1), let (f x2) = v2 in (gmap f g2)})\n\n-- syntax GR \"[\" [xv] \"+\" [xg] \",\" [v] \"]\" \";\" [gamma] \";\" [bigG] \"|-\" [g] = WFGraphRef xv xg v gamma bigG g;\n\n{- I'm struggling with this bit...\n\ndata WF2: xv -> xg -> v -> (List xv) -> (List xg)\n -> (g: G[Either xv xg, v]) -> Type where\n Lift: {xv, xg, v': Type}\n -> (WellFormed xv v' gamma g)\n -> WF2 xv xg v' gamma [] (gmap {x=xv} {x'=Either xv xg} {v=v'} Left g)\n\n Bundle: {auto d1: Disjoint gamma1 gamma2}\n -> {auto d2: Disjoint bigG1 bigG2}\n ...\n-}\n", "meta": {"hexsha": "4eac0672e680dec1bec1cb7ef2414bae7b5b1464", "size": 6405, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Graphs.idr", "max_stars_repo_name": "jimscarver/togl", "max_stars_repo_head_hexsha": "664731697c691137bb13a3b125ed405ced568b77", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2017-10-06T10:27:45.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-18T08:11:19.000Z", "max_issues_repo_path": "Graphs.idr", "max_issues_repo_name": "jimscarver/togl", "max_issues_repo_head_hexsha": "664731697c691137bb13a3b125ed405ced568b77", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 3, "max_issues_repo_issues_event_min_datetime": "2018-02-09T04:27:01.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-04T15:40:29.000Z", "max_forks_repo_path": "Graphs.idr", "max_forks_repo_name": "jimscarver/togl", "max_forks_repo_head_hexsha": "664731697c691137bb13a3b125ed405ced568b77", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2020-04-26T13:38:14.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-26T13:38:14.000Z", "avg_line_length": 36.186440678, "max_line_length": 110, "alphanum_fraction": 0.4977361436, "num_tokens": 2610, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.822189121808099, "lm_q2_score": 0.6791787056691698, "lm_q1q2_score": 0.5584133435648961}}
{"text": "module Printf\n\n-- Based on https://strathprints.strath.ac.uk/68800/\n\nimport Data.Vect\nimport src.GenericArity\n\ndata Chunk : Type where\n IntC : Chunk\n RawC : Char -> Chunk\n\nFormat : Type\nFormat = List Chunk\n\nsize' : Format -> Nat\nsize' [] = 0\nsize' (IntC :: xs) = 1 + size' xs\nsize' ((RawC x) :: xs) = size' xs\n\nparse : List Char -> Format\nparse [] = []\nparse ('%' :: 'd' :: xs) = IntC :: parse xs\nparse (x :: xs) = RawC x :: parse xs\n\nformat : (fmt : Format) -> Types (size' fmt)\nformat [] = []\nformat (IntC :: fmt) = Int :: format fmt\nformat ((RawC _) :: fmt) = format fmt\n\nassemble : (fmt : Format) -> Product (size' fmt) (format fmt) -> List String\nassemble [] () = []\nassemble (IntC :: fmt) (n, vs) = show n :: assemble fmt vs\nassemble ((RawC c) :: fmt) vs = pack (the (List Char) [c]) :: assemble fmt vs\n\nprintf : (str : String) -> Arrows (size' (parse (unpack str))) (format (parse (unpack str))) String\nprintf str = let fmt = parse (unpack str) in curryn (size' fmt) (concat . assemble fmt)\n\nlessThan : Int -> Int -> String\nlessThan = printf \"%d < %d\"\n", "meta": {"hexsha": "2ed2a2b3300f3f83e162021b67df3b4d6f9fb8a0", "size": 1062, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Printf.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/Printf.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/Printf.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.55, "max_line_length": 99, "alphanum_fraction": 0.6120527307, "num_tokens": 336, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8479677430095496, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.5583168019092792}}
{"text": "module Data.Fin\n\nimport Data.List1\nimport public Data.Maybe\nimport Data.Nat\nimport Decidable.Equality.Core\n\n%default total\n\n||| Numbers strictly less than some bound. The name comes from \"finite sets\".\n|||\n||| It's probably not a good idea to use `Fin` for arithmetic, and they will be\n||| exceedingly inefficient at run time.\n||| @ n the upper bound\npublic export\ndata Fin : (n : Nat) -> Type where\n FZ : Fin (S k)\n FS : Fin k -> Fin (S k)\n\n||| Coerce between Fins with equal indices\npublic export\ncoerce : {n : Nat} -> (0 eq : m = n) -> Fin m -> Fin n\ncoerce {n = S _} eq FZ = FZ\ncoerce {n = Z} eq FZ impossible\ncoerce {n = S _} eq (FS k) = FS (coerce (succInjective _ _ eq) k)\ncoerce {n = Z} eq (FS k) impossible\n\n%transform \"coerce-identity\" coerce = replace {p = Fin}\n\nexport\nUninhabited (Fin Z) where\n uninhabited FZ impossible\n uninhabited (FS f) impossible\n\nexport\nUninhabited (FZ = FS k) where\n uninhabited Refl impossible\n\nexport\nUninhabited (FS k = FZ) where\n uninhabited Refl impossible\n\nexport\nUninhabited (n = m) => Uninhabited (FS n = FS m) where\n uninhabited Refl @{nm} = uninhabited Refl @{nm}\n\nexport\nfsInjective : FS m = FS n -> m = n\nfsInjective Refl = Refl\n\nexport\nEq (Fin n) where\n (==) FZ FZ = True\n (==) (FS k) (FS k') = k == k'\n (==) _ _ = False\n\n||| Convert a Fin to a Nat\npublic export\nfinToNat : Fin n -> Nat\nfinToNat FZ = Z\nfinToNat (FS k) = S $ finToNat k\n\n||| `finToNat` is injective\nexport\nfinToNatInjective : (fm : Fin k) -> (fn : Fin k) -> (finToNat fm) = (finToNat fn) -> fm = fn\nfinToNatInjective FZ FZ _ = Refl\nfinToNatInjective (FS _) FZ Refl impossible\nfinToNatInjective FZ (FS _) Refl impossible\nfinToNatInjective (FS m) (FS n) prf =\n cong FS $ finToNatInjective m n $ succInjective (finToNat m) (finToNat n) prf\n\nexport\nCast (Fin n) Nat where\n cast = finToNat\n\n||| Convert a Fin to an Integer\npublic export\nfinToInteger : Fin n -> Integer\nfinToInteger FZ = 0\nfinToInteger (FS k) = 1 + finToInteger k\n\n-- %builtin NaturalToInteger Data.Fin.finToInteger\n\nexport\nShow (Fin n) where\n show = show . finToInteger\n\nexport\nCast (Fin n) Integer where\n cast = finToInteger\n\n||| Weaken the bound on a Fin by 1\npublic export\nweaken : Fin n -> Fin (S n)\nweaken FZ = FZ\nweaken (FS k) = FS $ weaken k\n\n||| Weaken the bound on a Fin by some amount\npublic export\nweakenN : (0 n : Nat) -> Fin m -> Fin (m + n)\nweakenN n FZ = FZ\nweakenN n (FS f) = FS $ weakenN n f\n\n||| Weaken the bound on a Fin using a constructive comparison\npublic export\nweakenLTE : Fin n -> LTE n m -> Fin m\nweakenLTE FZ LTEZero impossible\nweakenLTE (FS _) LTEZero impossible\nweakenLTE FZ (LTESucc _) = FZ\nweakenLTE (FS x) (LTESucc y) = FS $ weakenLTE x y\n\n||| Attempt to tighten the bound on a Fin.\n||| Return the tightened bound if there is one, else nothing.\nexport\nstrengthen : {n : _} -> Fin (S n) -> Maybe (Fin n)\nstrengthen {n = S _} FZ = Just FZ\nstrengthen {n = S _} (FS p) with (strengthen p)\n strengthen (FS _) | Nothing = Nothing\n strengthen (FS _) | Just q = Just $ FS q\nstrengthen _ = Nothing\n\n||| Add some natural number to a Fin, extending the bound accordingly\n||| @ n the previous bound\n||| @ m the number to increase the Fin by\npublic export\nshift : (m : Nat) -> Fin n -> Fin (m + n)\nshift Z f = f\nshift (S m) f = FS $ shift m f\n\n||| The largest element of some Fin type\npublic export\nlast : {n : _} -> Fin (S n)\nlast {n=Z} = FZ\nlast {n=S _} = FS last\n\n||| All of the Fin elements\npublic export\nallFins : (n : Nat) -> List1 (Fin (S n))\nallFins Z = FZ ::: []\nallFins (S n) = FZ ::: map FS (forget (allFins n))\n\nexport\nOrd (Fin n) where\n compare FZ FZ = EQ\n compare FZ (FS _) = LT\n compare (FS _) FZ = GT\n compare (FS x) (FS y) = compare x y\n\npublic export\nnatToFin : Nat -> (n : Nat) -> Maybe (Fin n)\nnatToFin Z (S _) = Just FZ\nnatToFin (S k) (S j) = FS <$> natToFin k j\nnatToFin _ _ = Nothing\n\n||| Convert an `Integer` to a `Fin`, provided the integer is within bounds.\n||| @n The upper bound of the Fin\npublic export\nintegerToFin : Integer -> (n : Nat) -> Maybe (Fin n)\nintegerToFin x Z = Nothing -- make sure 'n' is concrete, to save reduction!\nintegerToFin x n = if x >= 0 then natToFin (fromInteger x) n else Nothing\n\n||| Allow overloading of Integer literals for Fin.\n||| @ x the Integer that the user typed\n||| @ prf an automatically-constructed proof that `x` is in bounds\npublic export\nfromInteger : (x : Integer) -> {n : Nat} ->\n {auto 0 prf : (IsJust (integerToFin x n))} ->\n Fin n\nfromInteger {n} x {prf} with (integerToFin x n)\n fromInteger {n} x {prf = ItIsJust} | Just y = y\n\n-- %builtin IntegerToNatural Data.Fin.fromInteger\n\n||| Convert an Integer to a Fin in the required bounds/\n||| This is essentially a composition of `mod` and `fromInteger`\npublic export\nrestrict : (n : Nat) -> Integer -> Fin (S n)\nrestrict n val = let val' = assert_total (abs (mod val (cast (S n)))) in\n -- reasoning about primitives, so we need the\n -- 'believe_me'. It's fine because val' must be\n -- in the right range\n fromInteger {n = S n} val'\n {prf = believe_me {a=IsJust (Just val')} ItIsJust}\n\n--------------------------------------------------------------------------------\n-- DecEq\n--------------------------------------------------------------------------------\n\npublic export\nDecEq (Fin n) where\n decEq FZ FZ = Yes Refl\n decEq FZ (FS f) = No absurd\n decEq (FS f) FZ = No absurd\n decEq (FS f) (FS f')\n = case decEq f f' of\n Yes p => Yes $ cong FS p\n No p => No $ p . fsInjective\n\nnamespace Equality\n\n ||| Pointwise equality of Fins\n ||| It is sometimes complicated to prove equalities on type-changing\n ||| operations on Fins.\n ||| This inductive definition can be used to simplify proof. We can\n ||| recover proofs of equalities by using `homoPointwiseIsEqual`.\n public export\n data Pointwise : Fin m -> Fin n -> Type where\n FZ : Pointwise FZ FZ\n FS : Pointwise k l -> Pointwise (FS k) (FS l)\n\n infix 6 ~~~\n ||| Convenient infix notation for the notion of pointwise equality of Fins\n public export\n (~~~) : Fin m -> Fin n -> Type\n (~~~) = Pointwise\n\n ||| Pointwise equality is reflexive\n export\n reflexive : {k : Fin m} -> k ~~~ k\n reflexive {k = FZ} = FZ\n reflexive {k = FS k} = FS reflexive\n\n ||| Pointwise equality is symmetric\n export\n symmetric : k ~~~ l -> l ~~~ k\n symmetric FZ = FZ\n symmetric (FS prf) = FS (symmetric prf)\n\n ||| Pointwise equality is transitive\n export\n transitive : j ~~~ k -> k ~~~ l -> j ~~~ l\n transitive FZ FZ = FZ\n transitive (FS prf) (FS prg) = FS (transitive prf prg)\n\n ||| Pointwise equality is compatible with coerce\n export\n coerceEq : {k : Fin m} -> (0 eq : m = n) -> coerce eq k ~~~ k\n coerceEq {k = FZ} Refl = FZ\n coerceEq {k = FS k} Refl = FS (coerceEq _)\n\n ||| The actual proof used by coerce is irrelevant\n export\n congCoerce : {0 n, q : Nat} -> {k : Fin m} -> {l : Fin p} ->\n {0 eq1 : m = n} -> {0 eq2 : p = q} ->\n k ~~~ l ->\n coerce eq1 k ~~~ coerce eq2 l\n congCoerce eq\n = transitive (coerceEq _)\n $ transitive eq $ symmetric $ coerceEq _\n\n ||| Last is congruent wrt index equality\n export\n congLast : {m : Nat} -> (0 _ : m = n) -> last {n=m} ~~~ last {n}\n congLast Refl = reflexive\n\n export\n congShift : (m : Nat) -> k ~~~ l -> shift m k ~~~ shift m l\n congShift Z prf = prf\n congShift (S m) prf = FS (congShift m prf)\n\n ||| WeakenN is congruent wrt pointwise equality\n export\n congWeakenN : k ~~~ l -> weakenN n k ~~~ weakenN n l\n congWeakenN FZ = FZ\n congWeakenN (FS prf) = FS (congWeakenN prf)\n\n ||| Pointwise equality is propositional equality on Fins that have the same type\n export\n homoPointwiseIsEqual : {0 k, l : Fin m} -> k ~~~ l -> k === l\n homoPointwiseIsEqual FZ = Refl\n homoPointwiseIsEqual (FS prf) = cong FS (homoPointwiseIsEqual prf)\n\n ||| Pointwise equality is propositional equality modulo transport on Fins that\n ||| have provably equal types\n export\n hetPointwiseIsTransport :\n {0 k : Fin m} -> {0 l : Fin n} ->\n (0 eq : m === n) -> k ~~~ l -> k === rewrite eq in l\n hetPointwiseIsTransport Refl = homoPointwiseIsEqual\n\n export\n finToNatQuotient : k ~~~ l -> finToNat k === finToNat l\n finToNatQuotient FZ = Refl\n finToNatQuotient (FS prf) = cong S (finToNatQuotient prf)\n\n export\n weakenNeutral : (k : Fin n) -> weaken k ~~~ k\n weakenNeutral FZ = FZ\n weakenNeutral (FS k) = FS (weakenNeutral k)\n\n export\n weakenNNeutral : (0 m : Nat) -> (k : Fin n) -> weakenN m k ~~~ k\n weakenNNeutral m FZ = FZ\n weakenNNeutral m (FS k) = FS (weakenNNeutral m k)\n", "meta": {"hexsha": "e4724a5e03ae5859d259eb908d2adea6f3915e1a", "size": 8722, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/base/Data/Fin.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/Fin.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/Fin.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": 29.5661016949, "max_line_length": 92, "alphanum_fraction": 0.6210731484, "num_tokens": 2858, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.7634837689358857, "lm_q1q2_score": 0.5581513589253476}}
{"text": "> module SequentialDecisionProblems.DeterministicDefaults\n\n> import Control.Monad.Identity\n\n> import SequentialDecisionProblems.CoreTheory\n> import SequentialDecisionProblems.Utils\n\n> import Identity.Operations\n> import Identity.Properties\n\n> %default total\n> %auto_implicits off\n\n\nIn deterministic SDPs, |M = Identity|:\n\n> SequentialDecisionProblems.CoreTheory.M = \n> Identity\n\nThus, |M| is a functor:\n\n> SequentialDecisionProblems.CoreTheory.fmap = \n> Identity.Operations.fmap\n\n, |M| is a monad:\n\n> SequentialDecisionProblems.Utils.ret =\n> Identity.Operations.ret\n\n> SequentialDecisionProblems.Utils.bind =\n> Identity.Operations.bind\n\nMoreover, |M| is a container monad\n\n> SequentialDecisionProblems.CoreTheory.Elem =\n> Identity.Operations.Elem\n\n> SequentialDecisionProblems.CoreTheory.NotEmpty =\n> Identity.Operations.NonEmpty\n\n> SequentialDecisionProblems.CoreTheory.All =\n> Identity.Operations.All\n\n> SequentialDecisionProblems.CoreTheory.elemNotEmptySpec0 =\n> Identity.Properties.elemNonEmptySpec0\n\n> SequentialDecisionProblems.CoreTheory.elemNotEmptySpec1 =\n> Identity.Properties.elemNonEmptySpec1\n\n> SequentialDecisionProblems.CoreTheory.tagElem = \n> Identity.Operations.tagElem\n\n> SequentialDecisionProblems.CoreTheory.allElemSpec0 =\n> Identity.Properties.containerMonadSpec3\n\nand |All| and |NotEmpty| are finite and decidable:\n\n> SequentialDecisionProblems.Utils.finiteAll = \n> Identity.Properties.finiteAll\n\n> SequentialDecisionProblems.Utils.finiteNotEmpty = \n> Identity.Properties.finiteNonEmpty\n\n> SequentialDecisionProblems.Utils.decidableAll = \n> Identity.Properties.decidableAll\n\n> SequentialDecisionProblems.Utils.decidableNotEmpty = \n> Identity.Properties.decidableNonEmpty\n\n\n> {-\n\n> ---}\n\n", "meta": {"hexsha": "69550ee66ba3f300f05189a90870168f483d4470", "size": 1741, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "SequentialDecisionProblems/DeterministicDefaults.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/DeterministicDefaults.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/DeterministicDefaults.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.2133333333, "max_line_length": 59, "alphanum_fraction": 0.7989661114, "num_tokens": 399, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744850834648, "lm_q2_score": 0.682573740869499, "lm_q1q2_score": 0.558054874722875}}
{"text": "module PPM\n\n%default total\n\nrecord Color : Type where\n C : (red, green, blue : Bits8) -> Color\n\ndata PPM : Nat -> Nat -> Type where\n MkPPM: (x, y: Nat) ->\n (image : Vect x (Vect y Color)) ->\n PPM x y\n\ndata VectZipper : Nat -> Nat -> Type -> Type where\n VZ : (left : Vect n a) -> (right : Vect m a) -> VectZipper n m a\n\ntoVect : VectZipper n m a -> Vect (n + m) a\ntoVect (VZ l r) = reverse l ++ r\n\ngoLeft : VectZipper (S n) m a -> VectZipper n (S m) a\ngoLeft (VZ (x :: l) r) = VZ l (x :: r)\n\ngoRight : VectZipper n (S m) a -> VectZipper (S n) m a\ngoRight (VZ l (x :: r)) = VZ (x :: l) r\n\nzipper : Vect n a -> VectZipper 0 n a\nzipper v = VZ [] v\n\ninstance Cast Bits8 Int where\n cast = prim__zextB8_Int\n\ntoString : PPM n m -> String\ntoString (MkPPM x y image) = header ++ concatMap {t=Vect x} row image\n where header : String\n header = concat (the (List String)\n [ \"P3\\n\"\n , show x, \" \"\n , show y, \"\\n\"\n ])\n component : Bits8 -> String\n component b = show (cast {to=Int} b)\n pixel : Color -> String\n pixel (C r g b) = component r ++ \" \" ++\n component g ++ \" \" ++\n component b ++ \"\\n\"\n row : Vect n Color -> String\n row = concatMap pixel", "meta": {"hexsha": "c062d58c911951dee59bd842e70ccb6d4189e58b", "size": 1365, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "PPM.idr", "max_stars_repo_name": "david-christiansen/idris-raytracer", "max_stars_repo_head_hexsha": "cdd7f4ca0a8f707e4d3ad14522cdc3a11f4e270c", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2017-10-16T16:52:03.000Z", "max_stars_repo_stars_event_max_datetime": "2017-10-16T16:52:03.000Z", "max_issues_repo_path": "PPM.idr", "max_issues_repo_name": "david-christiansen/idris-raytracer", "max_issues_repo_head_hexsha": "cdd7f4ca0a8f707e4d3ad14522cdc3a11f4e270c", "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": "PPM.idr", "max_forks_repo_name": "david-christiansen/idris-raytracer", "max_forks_repo_head_hexsha": "cdd7f4ca0a8f707e4d3ad14522cdc3a11f4e270c", "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.6739130435, "max_line_length": 69, "alphanum_fraction": 0.495970696, "num_tokens": 421, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929002541068, "lm_q2_score": 0.7154239897159438, "lm_q1q2_score": 0.5580256326499033}}
{"text": "module Data.Pair.Predicates\n\n%default total\n%access public export\n\ndata PairEq : (prfSame : a -> a -> Type)\n -> (l : (a,a))\n -> (r : (a,a))\n -> Type\n where\n AreSame : (ad : prfSame a d)\n -> (bc : prfSame b c)\n -> PairEq prfSame (a,b) (c,d)\n\nfsNotSame : (decEq : (x : a) -> (y : a) -> Dec (prfSame x y))\n -> (contra : prfSame a1 d -> Void)\n -> PairEq prfSame (a1, b) (c, d)\n -> Void\nfsNotSame decEq contra (AreSame ad bc) = contra ad\n\nsfNotSame : (decEq : (x : a) -> (y : a) -> Dec (prfSame x y))\n -> (contra : prfSame b c -> Void)\n -> PairEq prfSame (a1, b) (c, d)\n -> Void\nsfNotSame decEq contra (AreSame ad bc) = contra bc\n\npairEq : {a : Type}\n -> {prfSame : a -> a -> Type}\n -> (decEq : (x,y : a) -> Dec (prfSame x y))\n -> (l,r : Pair a a)\n -> Dec (PairEq prfSame l r)\npairEq decEq (a, b) (c, d) with (decEq a d)\n pairEq decEq (a, b) (c, d) | (Yes prfAD) with (decEq b c)\n pairEq decEq (a, b) (c, d) | (Yes prfAD) | (Yes prfBC) = Yes (AreSame prfAD prfBC)\n pairEq decEq (a, b) (c, d) | (Yes prfAD) | (No contra) = No (sfNotSame decEq contra)\n\n pairEq decEq (a, b) (c, d) | (No contra) = No (fsNotSame decEq contra)\n", "meta": {"hexsha": "e3f52601584085a7cc83c990b7a83253794fca7b", "size": 1260, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Data/Pair/Predicates.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/Pair/Predicates.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/Pair/Predicates.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": 33.1578947368, "max_line_length": 88, "alphanum_fraction": 0.5063492063, "num_tokens": 477, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321796478255, "lm_q2_score": 0.6926419831347362, "lm_q1q2_score": 0.5580146705884299}}
{"text": "module Data.Crypto.Hash.MD5\n\nimport Data.Bits\nimport Data.Vect\n\nimport Data.Crypto.Hash\nimport Data.Crypto.Util\nimport Data.Mod\n\n%default total\n\n||| INSECURE!\npublic export\ndata MessageDigest5 : Type where\n MD5 : Vect 4 (Bits 32) -> MessageDigest5\n\ns : Vect 64 Nat\ns = concat (map (concat . replicate 4)\n [[7, 12, 17, 22],\n [5, 9, 14, 20],\n [4, 11, 16, 23],\n [6, 10, 15, 21]])\n\nK : Vect 64 (Bits 32)\n-- FIXME: `floor` is a `Double`, not integral.\n-- K = map (\\i => floor (abs (sin (i + 1)) * (2 `pow` 32))) [0..63]\nK = map intToBits\n [0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,\n 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,\n 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,\n 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,\n 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,\n 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,\n 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,\n 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,\n 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,\n 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,\n 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,\n 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,\n 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,\n 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,\n 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,\n 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391]\n\nimplementation Hash MessageDigest5 512 128 where\n initialize {m=m} {n=n} _ msg =\n let msgLength = m * n\n in let padSize = modToNat {n=512} (natToMod 448 - natToMod msgLength)\n in Basics.fst (partition' (append (concat msg)\n (or (shiftLeft (intToBits 64) (shiftRightLogical {n=512} (intToBits 1) (intToBits (cast (power 2 padSize)))))\n (intToBits (cast msgLength)))))\n initialContext _ = MD5 (map intToBits [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476])\n updateContext (MD5 [A, B, C, D]) chunk with (the (Vect 16 (Bits 32)) (partition chunk))\n | M = MD5 (zipWith plus [A, B, C, D] (foldl iteration [A, B, C, D] [0..63]))\n where iteration : Vect 4 (Bits 32) -> Fin 64 -> Vect 4 (Bits 32)\n iteration [A, B, C, D] i =\n let iNat = finToNat i\n in let (F, g) =\n if iNat < 16\n then ((B `and` C) `or` (complement B `and` D),\n iNat `tightmod` 16)\n else if iNat < 32\n then ((D `and` B) `or` (complement D `and` C),\n (iNat*5 + 1) `tightmod` 16)\n else if iNat < 48\n then (B `xor` (C `xor` D),\n (iNat*3 + 5) `tightmod` 16)\n else (C `xor` (B `or` complement D),\n (iNat*7) `tightmod` 16)\n in [C,\n B,\n B `plus` rotateLeft (index i s)\n ((A `plus` F) `plus` (index i K `plus` index g M)),\n D]\n finalize (MD5 context) = concat context\n\n-- Tests\n\ndummyMD5 : MessageDigest5\ndummyMD5 = MD5 (map intToBits [0, 0, 0, 0])\n\n-- shouldMatch_ : hashMessage {n=8} dummyMD5 [] = intToBits 0xd41d8cd98f00b204e9800998ecf8427e\n-- shouldMatch_ = Refl\n\nshouldMatch_a : hashMessage dummyMD5 (map (intToBits {n=8}) [97]) = intToBits 0x0cc175b9c0f1b6a831c399e269772661\nshouldMatch_a = Refl\n\nshouldMatch_abc : hashMessage dummyMD5 (map (intToBits {n=8}) [97, 98, 99]) = intToBits 0x900150983cd24fb0d6963f7d28e17f72\nshouldMatch_abc = Refl\n", "meta": {"hexsha": "255f576d054ea05b3d9246befc96a6137e3d5df5", "size": 3753, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Crypto/Hash/MD5.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/MD5.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/MD5.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": 41.7, "max_line_length": 150, "alphanum_fraction": 0.5654143352, "num_tokens": 1461, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673269042767, "lm_q2_score": 0.6859494485880927, "lm_q1q2_score": 0.5575858946652654}}
{"text": "= The Second Tale\n\n> module WhoStoleTheTarts.TheSecondTale\n>\n> %access export\n> %default total\n\nThis time, someone stole the flour!\n
\nFind the miscreant, and take his head off!\n
\n\n== Suspects\n\nWe know it was one of the March Hare, the Mad Hatter and the Dormouse.\n\n> data MarchHare\n>\n> data MadHatter\n>\n> data Dormouse\n>\n> SomeoneStoleTheFlour : Type\n> SomeoneStoleTheFlour = Either ( MarchHare, Not MadHatter, Not Dormouse)\n> $ Either (Not MarchHare, MadHatter, Not Dormouse)\n> (Not MarchHare, Not MadHatter, Dormouse)\n\n== Statements\n\nThe March Hare claims the Hatter stole it.\n\n> MarchHareStatement : (truth : Bool) -> Type\n> MarchHareStatement False = Not MadHatter\n> MarchHareStatement True = (Not MarchHare, MadHatter, Not Dormouse)\n\nThe thief told the truth...\n\n> MadHatterStatement : (truth : Bool) -> Type\n> MadHatterStatement False = Not MadHatter\n> MadHatterStatement True = (Not MarchHare, MadHatter, Not Dormouse)\n\n> DormouseStatement : (truth : Bool) -> Type\n> DormouseStatement False = Not Dormouse\n> DormouseStatement True = (Not MarchHare, Not MadHatter, Dormouse)\n\n== Revelation\n\n... and is the only one who did.\n\n> Revelation : Type\n> Revelation = Either ( (MarchHareStatement True, MarchHare)\n> , MadHatterStatement False\n> , DormouseStatement False )\n> ( Either ( MarchHareStatement False\n> , MadHatterStatement True\n> , DormouseStatement False )\n> ( MarchHareStatement False\n> , MadHatterStatement False\n> , DormouseStatement True ) )\n\n== Conclusion\n\n> lemma1 : SomeoneStoleTheFlour\n> -> (Not MarchHare, Not MadHatter)\n> -> Dormouse\n> lemma1 (Left (marchHare, _)) (toBlame, _)\n> = absurd (toBlame marchHare)\n> lemma1 (Right (Left (_, madHatter, _))) (_, toBlame)\n> = absurd (toBlame madHatter)\n> lemma1 (Right (Right (it, was, dormouse))) obviously\n> = dormouse\n\nGiven the [statements](#statements) above and the [revelation](#revelation),\n\n> Thief : SomeoneStoleTheFlour -> Revelation\n\n... we can conclude the Dormouse stole the flour.\n\n> -> (Not MarchHare, Not MadHatter, Dormouse)\n\nLet's assume the March Hare did it. If so, then they told the truth, which would\nmean that the Hatter stole the flour. They couldn't both have done it, so the\nMarch Hare must have lied, which means they and the Mad Hatter are innocent.\n\n> Thief (Left marchHare) (Left (((_, madHatter, _), _), toBlame, _))\n> = absurd (toBlame madHatter)\n> Thief (Right (Left (toBlame, _))) (Left ((_, marchHare), _))\n> = absurd (toBlame marchHare)\n\nIf it was neither the March Hare nor the Mad Hatter,\nthen it must've been the Dormouse.\n\n> Thief someone (Right (Left (notHatter, (notMarchHare, _), _)))\n> = let dormouse = lemma1 someone (notMarchHare, notHatter) in\n> (notMarchHare, notHatter, dormouse)\n> Thief (Right (Right dormouse)) _ = dormouse\n\nIf the Dormouse told the truth,\nthen they stole the flour.\n\n> Thief _ (Right (Right (_, _, dormouse))) = dormouse\n\n∎\n", "meta": {"hexsha": "7b461cf5fb52093b2bba8ffdc025ba66efe4605c", "size": 3183, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "src/WhoStoleTheTarts/TheSecondTale.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/TheSecondTale.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/TheSecondTale.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": 30.6057692308, "max_line_length": 80, "alphanum_fraction": 0.6566132579, "num_tokens": 877, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619177503205, "lm_q2_score": 0.6757646140788307, "lm_q1q2_score": 0.557142189671238}}
{"text": "module Gspider.Types.AttackFrame\n\n\nimport Data.Vect\n\nimport Core\nimport Types.RestrictedCharString\n\n\n%access private\n\n\n||| Represents a probabilistic attack frame.\n|||\n||| @ n the number of pending guesses at this frame\n||| @ m the number of made guesses at this frame\npublic export\ndata AttackFrame : (s : System) -> (n : Nat) -> (m : Nat) -> Type where\n -- Included for completeness.\n Empty : (d : Distribution s) ->\n AttackFrame s Z Z\n Initial : (p : Vect (S n) (RestrictedCharString s)) ->\n (d : Distribution s) ->\n AttackFrame s (S n) Z\n Ongoing : (p : Vect (S n) (RestrictedCharString s)) ->\n (g : Vect (S m) (RestrictedCharString s)) ->\n (d : Distribution s) ->\n (q : Double) ->\n AttackFrame s (S n) (S m)\n Terminal : (g : Vect (S m) (RestrictedCharString s)) ->\n (d : Distribution s) ->\n (q : Double) ->\n AttackFrame s Z (S m)\n\n\n||| Gets the probability of a password in a distribution given that it is not present in a collection.\n|||\n||| @ p the password\n||| @ d the distribution\n||| @ g the collection\ndistinctProb : (p : (RestrictedCharString s)) ->\n (d : Distribution s) ->\n (g : Vect n (RestrictedCharString s)) ->\n Double\ndistinctProb p d g = if elem p g then 0 else d p\n\n\n||| Advances an attack to the next frame.\n|||\n||| @ frame the frame to advance\nexport\nadvance : (frame : AttackFrame s (S n) m) -> AttackFrame s n (S m)\nadvance (Initial [p] d) = Terminal [p] d (d p)\nadvance (Initial (p :: rest@(p' :: ps)) d) = Ongoing rest [p] d (d p)\nadvance (Ongoing [p] g d q) = Terminal (p :: g) d (q + (distinctProb p d g))\nadvance (Ongoing (p :: rest@(p' :: ps)) g d q) = Ongoing rest (p :: g) d (q + (distinctProb p d g))\n\n\n||| Retreats an attack to the previous frame.\n|||\n||| @ frame the frame to retreat\nexport\nretreat : (frame : AttackFrame s n (S m)) -> AttackFrame s (S n) m\nretreat (Ongoing p [g] d q) = Initial (g :: p) d\nretreat (Ongoing p (g :: rest@(g' :: gs)) d q) = Ongoing (g :: p) rest d (q - (distinctProb g d rest))\nretreat (Terminal [g] d q) = Initial [g] d\nretreat (Terminal (g :: rest@(g' :: gs)) d q) = Ongoing [g] rest d (q - (distinctProb g d rest))\n", "meta": {"hexsha": "0a2ee1a5b9b8db6ecc6575c43e1909ef94d4405d", "size": 2244, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Types/AttackFrame.idr", "max_stars_repo_name": "sr-lab/gspider", "max_stars_repo_head_hexsha": "fa6259a141dfad6548fc44932e8d90924ab89ad2", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2019-07-04T07:56:15.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-04T07:56:15.000Z", "max_issues_repo_path": "src/Types/AttackFrame.idr", "max_issues_repo_name": "sr-lab/gspider", "max_issues_repo_head_hexsha": "fa6259a141dfad6548fc44932e8d90924ab89ad2", "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/Types/AttackFrame.idr", "max_forks_repo_name": "sr-lab/gspider", "max_forks_repo_head_hexsha": "fa6259a141dfad6548fc44932e8d90924ab89ad2", "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.0, "max_line_length": 102, "alphanum_fraction": 0.5895721925, "num_tokens": 672, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8080672135527632, "lm_q2_score": 0.6893056295505783, "lm_q1q2_score": 0.557005279357169}}
{"text": "module Main\n\nimport Data.Vect\nimport Data.Vect.Quantifiers\nimport System\n\n%default total\n\nfiveIsNotZero : Not (the Nat 5 = 0)\nfiveIsNotZero = \\Refl impossible\n\nthreeIsNotZero : Not (the Nat 3 = 0)\nthreeIsNotZero = \\Refl impossible\n\nmodFive : Nat -> Nat\nmodFive k = modNatNZ k 5 fiveIsNotZero\n\nmodThree : Nat -> Nat\nmodThree k = modNatNZ k 3 threeIsNotZero\n\nrecord FizzBuzzValue where\n constructor MkFizzBuzzValue\n i : Nat\n s : String\n\ndata FizzBuzzProp : FizzBuzzValue -> Type where\n FizzCase : (modThree x = 0) ->\n (Not (modFive x = 0)) ->\n FizzBuzzProp (MkFizzBuzzValue x \"Fizz\")\n BuzzCase : (Not (modThree x = 0)) ->\n (modFive x = 0) ->\n FizzBuzzProp (MkFizzBuzzValue x \"Buzz\")\n FizzBuzzCase : (modThree x = 0) ->\n (modFive x = 0) ->\n FizzBuzzProp (MkFizzBuzzValue x \"FizzBuzz\")\n NatCase : (Not (modThree x = 0)) ->\n (Not (modFive x = 0)) ->\n FizzBuzzProp (MkFizzBuzzValue x (show x))\n\ndata TotalOrderVect : (p : a -> a -> Type) -> (v : Vect n a) -> Type where\n EmptyVectCase : TotalOrderVect p []\n SingletonCase : TotalOrderVect p [x]\n ConsCase : (tailPrf : TotalOrderVect p (y::ys)) ->\n (headPrf : (p x y)) ->\n TotalOrderVect p (x :: y :: ys)\n\ndata FizzBuzzValueNatProp : (p : Nat -> Nat -> Type) ->\n (a : FizzBuzzValue) ->\n (b : FizzBuzzValue) ->\n Type where\n FromNatProp : (natProp : p (i a) (i b)) -> FizzBuzzValueNatProp p a b\n\noneIsNotMulThree : Not (modThree 1 = fromInteger 0)\noneIsNotMulThree Refl impossible\n\noneIsNotMulFive : Not (modFive 1 = fromInteger 0)\noneIsNotMulFive Refl impossible\n\nsafeHead : (Not (n = Z)) -> (Vect n a) -> a\nsafeHead {n = Z} nIsNotZP [] = void (nIsNotZP Refl)\nsafeHead {n = (S len)} nIsNotZP (y :: xs) = y\n\nsGTNotS : GT (S k) k\nsGTNotS {k = Z} = LTESucc LTEZero\nsGTNotS {k = (S n)} = LTESucc sGTNotS\n\nfizzBuzz : (n : Nat) ->\n (nIsNotZP : Not (n = Z)) ->\n (v : Vect n FizzBuzzValue **\n (All FizzBuzzProp v,\n n = (i (safeHead nIsNotZP v)),\n TotalOrderVect (FizzBuzzValueNatProp GT) v))\nfizzBuzz Z nIsNotZP = void $ nIsNotZP Refl\nfizzBuzz (S Z) _ = (_ ** ([NatCase oneIsNotMulThree oneIsNotMulFive], Refl, SingletonCase))\nfizzBuzz (S (S k)) _ = let (_::_ ** (fizzBuzzInTailP, skInHeadP, totalOrderPoof))\n = (fizzBuzz (S k) SIsNotZ) in\n case (decEq (modThree (S (S k))) 0, decEq (modFive (S (S k))) 0) of\n (Yes mulOfThreeP, No notMulOfFiveP) =>\n (_ ** (FizzCase mulOfThreeP notMulOfFiveP :: fizzBuzzInTailP,\n Refl,\n ConsCase totalOrderPoof $\n rewrite skInHeadP in FromNatProp sGTNotS))\n (No notMulOfThreeP, Yes mulOfFiveP) =>\n (_ ** (BuzzCase notMulOfThreeP mulOfFiveP :: fizzBuzzInTailP,\n Refl,\n ConsCase totalOrderPoof $\n rewrite skInHeadP in FromNatProp sGTNotS))\n (Yes mulOfThreeP, Yes mulOfFiveP) =>\n (_ ** (FizzBuzzCase mulOfThreeP mulOfFiveP :: fizzBuzzInTailP,\n Refl,\n ConsCase totalOrderPoof $\n rewrite skInHeadP in FromNatProp sGTNotS))\n (No notMulOfThreeP, No notMulOfFiveP) =>\n (_ ** (NatCase notMulOfThreeP notMulOfFiveP :: fizzBuzzInTailP,\n Refl,\n ConsCase totalOrderPoof $\n rewrite skInHeadP in FromNatProp sGTNotS))\n\nfizzBuzzDriver : (n : Nat) -> Maybe String\nfizzBuzzDriver n = case decEq n Z of\n Yes _ => Nothing\n No nIsNotZP => Just $ concatMap (++\"\\n\") $\n reverse $\n map s $\n fst $\n fizzBuzz n nIsNotZP\n\npartial\nmain : IO ()\nmain = do\n args <- getArgs\n case args of\n (_ :: n :: []) => case all isDigit $ unpack n of\n True => case fizzBuzzDriver $ cast n of\n Just fizzBuzzString => do putStr fizzBuzzString\n exitSuccess\n Nothing => do putStrLn \"The argument can't be zero.\"\n exitFailure\n False => do putStrLn \"The argument isn't a number.\"\n exitFailure\n _ => do putStrLn \"Wrong number of arguments.\"\n exitFailure\n", "meta": {"hexsha": "1bfb267fd94234e4402544e73844c07809704d61", "size": 5168, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "FizzBuzz.idr", "max_stars_repo_name": "batonius/idris-fizzbuzz", "max_stars_repo_head_hexsha": "971915c34bb7447f941fb6442ee7d8cf09376485", "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": "FizzBuzz.idr", "max_issues_repo_name": "batonius/idris-fizzbuzz", "max_issues_repo_head_hexsha": "971915c34bb7447f941fb6442ee7d8cf09376485", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 1, "max_issues_repo_issues_event_min_datetime": "2021-01-24T15:40:58.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-24T15:40:58.000Z", "max_forks_repo_path": "FizzBuzz.idr", "max_forks_repo_name": "batonius/idris-fizzbuzz", "max_forks_repo_head_hexsha": "971915c34bb7447f941fb6442ee7d8cf09376485", "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.0162601626, "max_line_length": 95, "alphanum_fraction": 0.4785216718, "num_tokens": 1302, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8596637505099168, "lm_q2_score": 0.6477982247516797, "lm_q1q2_score": 0.556888651463695}}
{"text": "Data Vect : Nat -> Type -> Type\n Nil : Vect 0 a\n (::) : a -> Vect n a -> Vect (n + 1) a\n", "meta": {"hexsha": "18dc006401b0d9870e988fcced746b16719480f5", "size": 90, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "proposal/code/vectDef.idr", "max_stars_repo_name": "RossMeikleham/MSci-Project", "max_stars_repo_head_hexsha": "4e1e3e08bf8440add18b4a87b96ca42920336e14", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2015-10-20T11:17:45.000Z", "max_stars_repo_stars_event_max_datetime": "2015-10-20T11:17:45.000Z", "max_issues_repo_path": "proposal/code/vectDef.idr", "max_issues_repo_name": "RossMeikleham/MSci-Project", "max_issues_repo_head_hexsha": "4e1e3e08bf8440add18b4a87b96ca42920336e14", "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": "proposal/code/vectDef.idr", "max_forks_repo_name": "RossMeikleham/MSci-Project", "max_forks_repo_head_hexsha": "4e1e3e08bf8440add18b4a87b96ca42920336e14", "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.5, "max_line_length": 40, "alphanum_fraction": 0.4666666667, "num_tokens": 36, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8740772482857834, "lm_q2_score": 0.6370307806984445, "lm_q1q2_score": 0.5568141118662407}}
{"text": "module Data.List.Extra\n\n%default total\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", "meta": {"hexsha": "83a02f5685436cc3e61aa222798e408761f0d77e", "size": 296, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/src/Data/List/Extra.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/List/Extra.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/List/Extra.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.6666666667, "max_line_length": 60, "alphanum_fraction": 0.6351351351, "num_tokens": 88, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7853085909370422, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.5567988120716669}}
{"text": "module Decidable.Decidable\n\nimport Data.Rel\nimport Data.Fun\n\n%default total\n\npublic export\nisNo : Dec a -> Bool\nisNo (Yes _) = False\nisNo (No _) = True\n\npublic export\nisYes : Dec a -> Bool\nisYes (Yes _) = True\nisYes (No _) = False\n\n||| Proof that some `Dec` is actually `Yes`\npublic export\ndata IsYes : Dec a -> Type where\n ItIsYes : IsYes (Yes prf)\n\npublic export\nUninhabited (IsYes (No contra)) where\n uninhabited ItIsYes impossible\n\n||| Decide whether a 'Dec' is 'Yes'\npublic export\nisItYes : (v : Dec a) -> Dec (IsYes v)\nisItYes (Yes _) = Yes ItIsYes\nisItYes (No _) = No absurd\n\n||| An n-ary relation is decidable if we can make a `Dec`\n||| of its result type for each combination of inputs\npublic export\nIsDecidable : (k : Nat) -> (ts : Vect k Type) -> Rel ts -> Type\nIsDecidable k ts p = liftRel ts p Dec\n\n||| Interface for decidable n-ary Relations\npublic export\ninterface Decidable k ts p where\n total decide : IsDecidable k ts p\n\n||| Given a `Decidable` n-ary relation, provides a decision procedure for\n||| this relation.\ndecision : (ts : Vect k Type) -> (p : Rel ts) -> (Decidable k ts p) => liftRel ts p Dec\ndecision ts p = decide {ts} {p}\n\nusing (a : Type, x : a)\n public export\n data Given : Dec a -> Type where\n Always : Given (Yes x)\n", "meta": {"hexsha": "d65f276b20b6d9b74a690b15b2f2d4add843c207", "size": 1258, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/base/Decidable/Decidable.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/Decidable/Decidable.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/Decidable/Decidable.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": 23.7358490566, "max_line_length": 87, "alphanum_fraction": 0.6836248013, "num_tokens": 390, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7853085708384736, "lm_q2_score": 0.7090191337850932, "lm_q1q2_score": 0.556798802649904}}
{"text": "import Control.Monad.State\n\nincrease : Nat -> State Nat ()\nincrease inc =\n do\n current <- get\n put (current + inc)\n\nupdate : (stateType -> stateType) -> State stateType ()\nupdate f =\n do\n state <- get\n put (f state)\n\nincrease' : Nat -> State Nat ()\nincrease' inc = update (+inc)\n", "meta": {"hexsha": "dec1621e129c009dac3dd39c7e549e61d17917d4", "size": 313, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris-exercises/State.idr", "max_stars_repo_name": "0nkery/tt-tutorials", "max_stars_repo_head_hexsha": "a39926989c2f39c718893b99bd857b6d51a172b0", "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-exercises/State.idr", "max_issues_repo_name": "0nkery/tt-tutorials", "max_issues_repo_head_hexsha": "a39926989c2f39c718893b99bd857b6d51a172b0", "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-exercises/State.idr", "max_forks_repo_name": "0nkery/tt-tutorials", "max_forks_repo_head_hexsha": "a39926989c2f39c718893b99bd857b6d51a172b0", "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": 18.4117647059, "max_line_length": 55, "alphanum_fraction": 0.5782747604, "num_tokens": 77, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.7549149813536518, "lm_q1q2_score": 0.5564917405955248}}
{"text": "module Toolkit.Data.Rig\n\nimport public Decidable.Equality\nimport public Data.Vect\n\n%default total\n\npublic export\ndata TyRig = None | One | Tonne\n\npublic export\nnoneNotOne : (None = One) -> Void\nnoneNotOne Refl impossible\n\npublic export\nnoneNotTonne : (None = Tonne) -> Void\nnoneNotTonne Refl impossible\n\npublic export\noneNotTonne : (One = Tonne) -> Void\noneNotTonne Refl impossible\n\npublic export\nDecEq TyRig where\n decEq None None = Yes Refl\n decEq None One = No noneNotOne\n decEq None Tonne = No noneNotTonne\n decEq One None = No (negEqSym noneNotOne)\n decEq One One = Yes Refl\n decEq One Tonne = No oneNotTonne\n decEq Tonne None = No (negEqSym noneNotTonne)\n decEq Tonne One = No (negEqSym oneNotTonne)\n decEq Tonne Tonne = Yes Refl\n\n\npublic export\nplus : TyRig -> TyRig -> TyRig\nplus None None = None\nplus None One = One\nplus None Tonne = Tonne\nplus One None = One\nplus One One = Tonne\nplus One Tonne = Tonne\nplus Tonne None = Tonne\nplus Tonne One = Tonne\nplus Tonne Tonne = Tonne\n\npublic export\nmultiply : TyRig -> TyRig -> TyRig\nmultiply None None = None\nmultiply None One = None\nmultiply None Tonne = None\nmultiply One None = None\nmultiply One One = One\nmultiply One Tonne = Tonne\nmultiply Tonne None = None\nmultiply Tonne One = Tonne\nmultiply Tonne Tonne = Tonne\n\npublic export\nproduct : Vect n TyRig -> Vect n TyRig -> Vect n TyRig\nproduct [] [] = []\nproduct (x :: xs) (y :: ys) = multiply x y :: product xs ys\n\npublic export\nsum : Vect n TyRig -> Vect n TyRig -> Vect n TyRig\nsum [] [] = []\nsum (x :: xs) (y :: ys) = plus x y :: sum xs ys\n", "meta": {"hexsha": "b10d4d58219d259dd1dff220ec5c6d3a9525adf3", "size": 1558, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Toolkit/Data/Rig.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/Rig.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/Rig.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": 22.5797101449, "max_line_length": 59, "alphanum_fraction": 0.716944801, "num_tokens": 497, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324803738429, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.5564562680147984}}
{"text": "module VQE\n\nimport Data.Nat\nimport Data.Vect\nimport Unitary\nimport Control.Linear.LIO\nimport Lemmas\nimport QStateT\nimport Injection\nimport LinearTypes\nimport Complex\nimport System.Random\nimport QuantumOp\nimport RandomUtilities\n\n%default total\n\n-- Example of code where quantum and classical information interact\n-- The VQE (Variational Quantum Eigensolver) algorithm finds the lowest eigenvalue for an Hamiltonian operator\n-- More precisely, we suppose that the eigenstate corresponding to the lowest eigenvalue is given by some ansatz\n-- that depends on some parameters, and we optimize the value of the parameters, to find the eigenvalue.\n\n\n-- The next lines of code explain how the ansatz is given in general. The ansatz has some depth p, and all parameters\n-- the ansatz is depending on are given by two matrices of angles, represented by the RotationAnglesMatrix type.\n\n\n||| Type for the matrices of rotation angles\n|||\n||| Matrix of size (n+1) * m\npublic export\nRotationAnglesMatrix : Nat -> Nat -> Type\nRotationAnglesMatrix n m = Vect (S n) (Vect m Double)\n\n||| Unitary operator used for linear entanglement\n|||\n||| n -- The arity of the operator\nexport\nlinearEntanglement : (n : Nat) -> Unitary n\nlinearEntanglement 0 = IdGate\nlinearEntanglement 1 = IdGate\nlinearEntanglement (S (S n)) = \n let circ = IdGate {n = 1} # linearEntanglement (S n)\n in circ . (CNOT 0 1 IdGate)\n\n||| Unitary operator, tensor product of phase gates\n|||\n||| n -- The arity of the operator\n||| phases -- The vector of phases\ntensorRzs : {n : Nat} -> (phases : Vect n Double) -> Unitary n\ntensorRzs phases = tensorMapSimple (map (\\phase => RzGate phase) phases)\n\n||| Unitary operator, tensor product of Ry gates\n|||\n||| n -- The arity of the operator\n||| phases -- The vector of phases for the Ry gates\ntensorRys : {n : Nat} -> (phases : Vect n Double) -> Unitary n\ntensorRys phases = tensorMapSimple (map (\\phase => RyGate phase) phases)\n\n\n||| The overall unitary operator for VQE, the ansatz\n|||\n||| n -- The arity of the operator\n||| depth -- The depth of the ansatz, i.e. the number of repetitions of the pattern\n||| phasesRy -- The vector of phases for all the Ry rotations\n||| phasesRz -- The vector of phases for all the phase gates\n||| output -- The overall unitary operator for VQE, the ansatz\nexport\nansatz : (n : Nat) -> (depth : Nat) -> \n (phasesRy : RotationAnglesMatrix depth n) -> \n (phasesRz : RotationAnglesMatrix depth n) ->\n Unitary n\nansatz n 0 [phaseRy] [phaseRz] = tensorRzs phaseRz . tensorRys phaseRy\nansatz n (S d) (phaseRy :: phasesRy) (phaseRz :: phasesRz) = \n let circ1 = ansatz n d phasesRy phasesRz \n in circ1 . linearEntanglement n . tensorRzs phaseRz . tensorRys phaseRy\n\n\n\n\n------------- THE HAMILTONIAN -------------------------------------------------------\n\n-- The ansatz gives us some vector |psi>, that depends on some parameters\n-- We want to find the minimum value of over all possible parameters\n-- To do that, we need a way to compute .\n\n-- This is easy if H is an tensor product of Pauli Matrices. In this case, one can build a circuit U_H\n-- such that, if we build the circuit U_H|psi> and measure the first qubit, then\n-- is equal to x - y where x (resp.y) is the probability of measuring 0 (resp. 1)\n\n\n-- More generally, if H is a sum of tensor product of Pauli Matrices, say H = a_1 H_1 + ... a_k H_k\n-- then one can obtain by computing separately each using the previous idea\n\n-- As a consequence, for all intent and purposes here, we suppose that Hamiltonians are given by linear combinations of\n-- tensor product of Pauli Matrices.\n-- This is represented by the type Hamiltonian below, that is a list of pairs (coefficient, tensor product of pauli matrix)\n\n||| Data type for the the Pauli matrices X,Y,Z and Identity\npublic export\ndata PauliAtomic : Type where\n PauliI : PauliAtomic\n PauliX : PauliAtomic\n PauliY : PauliAtomic\n PauliZ : PauliAtomic\n\n||| Tensor product of n Pauli matrices represented as a vector\n||| n -- number of qubits\npublic export\nPauliBasis : Nat -> Type\nPauliBasis n = Vect n PauliAtomic\n\n||| Decomposition of Hamiltonian as sum of Pauli matrices\n||| Hamiltonian = a_1P_1 + a_2P_2 + ... + a_kP_k\n||| n -- number of qubits\npublic export\nHamiltonian : Nat -> Type\nHamiltonian n = List (Double, PauliBasis n)\n\n-- Now the next lines of code explain how to obtain the value of , first for a tensor product of Pauli matrices, then more generally.\n\n-- First here is the definition of U_H, the unitary s.t. measuring U_H|psi> makes us able to compute :\n\n--------------------- COMPUTE THE ENERGY ------------------------------\n\n-- The value of the energy can be computed by applying a unitary operator U_H to |psi> and mesuring the first qubit\n-- Here the operator U_H uses one more qubits than H. It is possible to use the exact same number of qubits, but the code is easier this way.\n\n\n||| With a tensor product of Pauli matrices, compute the corresponding unitary operator U_H\n|||\n||| n -- number of qubits\n||| h -- vector that represents the tensor product of Pauli matrices\n||| output -- U_h\nencodingUnitary : {n : Nat} -> (h : PauliBasis n) -> Unitary (S n)\nencodingUnitary [] = IdGate\nencodingUnitary {n = S k} (PauliI :: xs) = rewrite sym $ lemmaplusOneRight k in (encodingUnitary xs) # IdGate {n=1}\nencodingUnitary {n = S k} (PauliX :: xs) = \n let p1 = lemmakLTSk k\n in rewrite sym $ lemmaplusOneRight k in CNOT (S k) 0 (H (S k) ((encodingUnitary xs) # IdGate {n=1}))\nencodingUnitary {n = S k} (PauliY :: xs) =\n let p1 = lemmakLTSk k \n in rewrite sym $ lemmaplusOneRight k in CNOT (S k) 0 (H (S k) (S (S k) ((encodingUnitary xs) # IdGate {n=1})))\nencodingUnitary {n = S k} (PauliZ :: xs) = \n let p1 = lemmakLTSk k\n in rewrite sym $ lemmaplusOneRight k in CNOT (S k) 0 ((encodingUnitary xs) # IdGate {n=1})\n\n\n-- the next function computes , for H a tensor product of Pauli Matrices\n-- This is the function that needs to run the quantum circuit\n-- As explained above, to obtain , we produce a circuit for U_H|psi> and then measure the first qubit\n-- The value of is then equal to the probability of measuring 0 minus the probability of measuring 1\n-- the following code runs the whole experiment nSamples times,\n-- and records the number of time we measure 0 and the number of times we measure 1 and returns the difference between the two quantities\n-- if nSamples is big enough, then is therefore well approximated by the result of this function divided by the number of samples.\n\n\n||| Computes an approximation of when H is a tensor product of Pauli Matrices\n||| More precisely, is equal to the result of this function divided by nSamples\n|||\n||| n -- number of qubits\n||| p -- tensor product of Pauli matrices\n||| nSamples -- the number of time we sample\n||| circuit -- the state |psi>\n||| output -- computed energy\ncomputeEnergyPauli : QuantumOp t => (n : Nat) -> (p : PauliBasis n) -> (nSamples : Nat) -> (circuit : Unitary n) -> IO Double\ncomputeEnergyPauli n p 0 circuit = pure 0\ncomputeEnergyPauli n p (S nSamples) circuit = do\n let encodingCircuit = encodingUnitary p\n (b :: _) <- run (do\n qs <- newQubits {t} (S n)\n qs <- applyUnitary qs ( (IdGate {n=1}) # circuit)\n qs <- applyUnitary qs encodingCircuit\n measureAll qs\n )\n rest <- computeEnergyPauli {t} n p nSamples circuit\n if (not b) then pure $ 1 + rest else pure $ rest - 1\n\n\n-- the next function computes for a general hamiltonian H, expressed as a linear combination of tensor product of Pauli Matrices\n-- we just have to call the function computeEnergyPauli for each element inside the linear combination:\n\n||| Compute an approximation of for a general Hamiltonian H\n|||\n||| n -- number of qubits\n||| h -- the hamiltonian of the problem\n||| nSamples -- the number of time we sample for each component of H\n||| circuit -- the state |psi>\n||| output -- computed energy\ncomputeEnergy : QuantumOp t => (n : Nat) -> (h : Hamiltonian n) -> (nSamples : Nat) -> (circuit : Unitary n) -> IO Double\ncomputeEnergy n [] nSamples circuit = pure 0\ncomputeEnergy n ((r, p) :: hs) nSamples circuit = do\n res1 <- computeEnergy {t} n hs nSamples circuit\n res2 <- computeEnergyPauli {t} n p nSamples circuit\n pure $ res1 + r*res2/(cast nSamples)\n\n\n\n--------------------- CLASSICAL OPTIMISATION ------------------------\n\n\n--- The energy that is compute by the function computeEnergy is fed to the function classicalOptimisation before\n--- That will produces new parameters for the ansatz to try, based on the value of on all previous runs\n\n\n--- This function should use general optimisation techniques, like for instance the Nelder-Mead method\n--- For simplicity, we opted instead for a function that returns random parameters\n\n\n||| Generate a matrix of size (n+1) * m of random Double\nexport\nrandomMatrix : (n : Nat) -> (m : Nat) -> IO (RotationAnglesMatrix n m)\nrandomMatrix 0 m = do\n xs <- randomVect m\n pure [xs]\nrandomMatrix (S n) m = do\n xs <- randomVect m\n ys <- randomMatrix n m\n pure (xs :: ys)\n\n\n\n||| The (probabilistic) classical optimisation procedure for VQE.\n||| IO output allows us to use probabilistic optimisation procedures.\n||| Given all previously observed information, determine new rotation angles for the next VQE run.\n||| We ask for the function to be able to return also parameters for the very first ansatz (that is, the function\n||| will be called for the first time with an empty vector of previous information)\n||| Remark: we randomly generate the next rotation angles for simplicity.\n|||\n||| k -- number of previous iterations of the algorithm\n||| n -- arity of the ansatz circuit\n||| depth -- depth of the ansatz circuit\n||| h -- hamiltonian of the problem\n||| previous_info -- previously used parameters and measurement outcomes\n||| output -- new rotation angles for the next run of VQE \nclassicalOptimisation : {n : Nat} -> (depth : Nat) ->\n (h : Hamiltonian n) ->\n (previous_info : Vect k (RotationAnglesMatrix depth n, RotationAnglesMatrix depth n, Double)) ->\n IO (RotationAnglesMatrix depth n, RotationAnglesMatrix depth n)\nclassicalOptimisation depth h previous_info = do\n phasesRy <- randomMatrix depth n\n phasesRz <- randomMatrix depth n\n pure (phasesRy, phasesRz)\n\n\n\n\n-----------------------PUTTING QUANTUM AND CLASSICAL PARTS TOGETHER -------------------------\n\n-- We now put everything together\n-- This function will run the whole process k times, computing at each step, and calling the classical optimiser to obtain\n-- the next value of |psi> to test\n\n\n||| Helper function for VQE\n||| n -- number of qubits\n||| h -- the hamiltonian of the problem\n||| nSamples -- number of times we sample to compute \n||| k -- number of iterations of the algorithm\n||| depth -- depth of the ansatz circuit\n||| output -- all observed information : rotation angles and computed energies\nVQE': QuantumOp t =>\n (n : Nat) -> (h : Hamiltonian n) -> (nSamples : Nat) -> (k : Nat) -> (depth : Nat) ->\n IO (Vect k (RotationAnglesMatrix depth n, RotationAnglesMatrix depth n, Double))\nVQE' n h nSamples 0 depth = pure []\nVQE' n h nSamples (S k) depth = do\n previous_info <- VQE' {t} n h nSamples k depth \n (phasesRy, phasesRz) <- classicalOptimisation depth h previous_info\n let circuit = ansatz n depth phasesRy phasesRz\n energy <- computeEnergy {t} n h nSamples circuit\n pure $ (phasesRy, phasesRz, energy) :: previous_info\n\n\n\n--- The VQE algorithm just calls the previous function, and returns the minimum value of that was observed\n--- Note that, in practice, if the classical Optimiser does their job correctly, the minimum value of \n--- is very likely to be obtained in the last iteration. As we use a random function instead of an optimiser, this is\n--- not true, so we take the minimum among all runs.\n\n||| VQE algorithm\n||| n -- number of qubits\n||| h -- the hamiltonian of the problem\n||| nSamples -- number of times we sample to compute \n||| k -- number of iterations of the algorithm\n||| depth -- depth of the ansatz circuit\n||| output -- the lowest computed energy\nexport\nVQE : QuantumOp t =>\n (n : Nat) -> (h : Hamiltonian n) -> (nSamples : Nat) -> (k : Nat) -> (depth : Nat) ->\n IO Double\nVQE n h nSamples k depth = do\n observed_info <- VQE' {t=t} n h nSamples (S k) depth\n let energies = map (\\(_, _, r) => r) observed_info\n pure $ foldl min (head energies) energies\n\n\n\n\n", "meta": {"hexsha": "2faa14a97117fe57ff3ceb54242f4fdc8dfe3773", "size": 12860, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "VQE.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": "VQE.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": "VQE.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": 43.0100334448, "max_line_length": 146, "alphanum_fraction": 0.6867807154, "num_tokens": 3523, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9046505325302034, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.5564395560454704}}
{"text": "module Linear\n\nimport ZZ\nimport Rationals\nimport Data.Vect\nimport GCDZZ\nimport ZZUtils\n\n%default total\n%access public export\n\n-- Old code. It has been superseded by DiophantineSolver.\n\n{-\n\nNatToZZ: Nat -> ZZ\nNatToZZ Z = 0\nNatToZZ (S k) = (NatToZZ k) + 1\n\nFST: (Nat,Nat) -> Nat --some issues with fst\nFST (a, b) = a\n\nSND: (Nat,Nat) -> Nat --some issues with snd\nSND (a, b) = b\n\nfindSignDiff: (b: ZZ) -> (c: ZZ) -> ZZ\nfindSignDiff b c = if (b>c) then 1 else if (b (b: Nat) -> (Nat, Nat)\nEucl Z b = (Z,Z)\nEucl (S k) b = case (lte (S (S k)) b) of\n False => (S(fst(Eucl (minus (S k) b) b)), snd(Eucl (minus (S k) b) b))\n True => (Z, S k)\n\nisFactor : Nat -> Nat -> Type\nisFactor m n = (k : Nat ** (m * k = n)) -- will be useful in solving Diophantine equations:\n -- if the denominator is a factor of the numerator, there is an integer solution\n\nis_a_zero: (a: ZZ) -> Bool\nis_a_zero (Pos Z) = True\nis_a_zero (Pos (S k)) = False\nis_a_zero (NegS k) = False\n-}\n\ndata SolExists : Type where\n YesExists : SolExists\n DNExist : SolExists\n\nApZZ : (f: ZZ -> ZZ)-> n = m -> f n = f m -- like apNat, but for ZZ\nApZZ f Refl = Refl\n\n-- Helper functions for the case ax = 0 --\n\nZeroSum: (a: ZZ) -> (b: ZZ) -> (a = 0) -> (b = 0) -> (a + b = 0) --sum of two zeroes is zero\nZeroSum a b prf prf1 = rewrite prf in\n rewrite (plusZeroLeftNeutralZ (b)) in\n prf1\n\n\ntriviality1: (a: ZZ) -> (b: ZZ) -> (b = 0) -> (a*b=0) -- premultiplying 0 by anything returns 0\ntriviality1 a b prf = trans (apZZ (\\x => a*x) b 0 prf) (multZeroRightZeroZ(a))\n\ntriviality2: (a: ZZ) -> (0*a=0) -- 0 times anything is zero\ntriviality2 a = multZeroLeftZeroZ(a)\n\ntriviality3: (a: ZZ) -> (a*0=0) -- 0 times anything is zero\ntriviality3 a = multZeroRightZeroZ(a)\n\nZeroProof: (a: ZZ) -> (b: ZZ) -> (b = 0) -> (0*a + 1*b = 0) -- shows that the rational number (0,1) satisfies ax = 0\nZeroProof a b prf = trans (trans (ApZZ (\\x=> x + 1*b) (triviality2 a)) (ApZZ (\\x => 0 + x) (triviality1 1 b prf))) (ZeroSum 0 0 Refl Refl)\n\n-- Helper functions for the case ax + b = 0\n\ntriviality4: (a: ZZ) -> (b: ZZ) -> (a*b = b*a)\ntriviality4 a b = multCommutativeZ a (b)\n\ntriviality5: (a: ZZ) -> (b: ZZ) -> (a*(-b)+b*a = a*(-b) + a*b )\ntriviality5 a b = ApZZ (\\x=> a*(-b) + x) (triviality4 b a)\n\ntriviality6: (a: ZZ) -> (b: ZZ) -> ( (a*(-b)) + (a*b) = a*( (-b)+b ) )\ntriviality6 a b = sym ( multDistributesOverPlusRightZ a (-b) b )\n\ntriviality7: (a: ZZ) -> (b: ZZ) -> ( a*((-b) + b) = 0)\ntriviality7 a b = trans (ApZZ (\\x => a*x) (plusNegateInverseRZ(b))) (triviality3(a))\n\nSolutionProof: (a: ZZ) -> (b: ZZ) -> (a*(-b)+b*a=0)\nSolutionProof a b = trans (trans (triviality5 a b) (triviality6 a b)) (triviality7 a b)\n\n--Solving a linear equation ax + b = 0 in the case when b = 0 (Basically, this shows that ax=0 is uniquely solved by (0,1))\n\ntrivialeqSolver : (a: ZZ) -> (b : ZZ) -> (b = 0) -> Either (x : ZZPair ** ( (SolExists, (( (fst x)*a + (snd x)*b = 0 ),(NotZero (snd x)))))) (SolExists)\ntrivialeqSolver a b prf = Left (((0,1) ** (YesExists, ((ZeroProof a b prf), PositiveZ))))\n\n-- Solving the linear equation ax+b = 0 in general\n\neqSolver : (a: ZZ) -> (b : ZZ) -> (NotZero a) -> (NotZero b) -> Either (x : ZZPair ** ( (SolExists, a*(fst x) + b*(snd x) = 0), NotZero (snd x)) ) (SolExists)\neqSolver a b x y = Left ((-b, a) ** ((YesExists, (SolutionProof a b)), x)) -- The solution is (-b/a), a rational number, with proof.\n\n-- Helper functions for ax + b = c\n\nhelper1: (a: ZZ) -> (b: ZZ) -> (c: ZZ) -> (a*(c+(-b))= a*c + a*(-b))\nhelper1 a b c = multDistributesOverPlusRightZ (a) (c) (-b)\n\nhelper2: (a: ZZ) -> (b: ZZ) -> (c: ZZ) -> ( a*(c-b) + b*a = a*c+ a*(-b)+ b*a )\nhelper2 a b c = ApZZ (\\x => x+ b*a) (helper1 (a) (b) (c))\n\nhelper3: (a: ZZ) -> (b: ZZ) -> (a*(-b)+b*a= 0)\nhelper3 a b = trans (trans (triviality5 a b) (triviality6 a b)) (triviality7 a b)\n\nhelper4: (a: ZZ) -> (b: ZZ) -> (c: ZZ) -> (a*c + a*(-b) + b*a = a*c)\nhelper4 a b c = rewrite sym (plusAssociativeZ (a*c) (a*(-b)) (b*a)) in\n rewrite helper3 a b in\n rewrite plusZeroRightNeutralZ (multZ a c) in Refl\n\nGeneralProof: (a: ZZ) -> (b: ZZ) -> (c: ZZ) -> ( a*(c-b) + b*a = a*c )\nGeneralProof a b c = trans (helper2 a b c) (helper4 a b c)\n\n-- Solving the linear equation ax + b = c (2x +3 = 7, for example) over the rationals\n\nGeneralEqSolver: (a: ZZ) -> (b: ZZ) -> (c: ZZ) -> (a0: NotZero a) ->\n (x : ZZPair ** ( (SolExists, a*(fst x) + b*(snd x) = (snd x)*c), (NotZero (snd x))) )\nGeneralEqSolver a b c a0 = ( ( (c-b) , a ) ** ( (YesExists, (GeneralProof a b c)), a0 )) -- Solves the equation with proof\n\n{-\n\n-- This is previously used code. It has been superseded by DiophantineSolver\n\n-- Now, we can use the rational solution of the linear equation ax + b = c to check whether this equation has an integer\n-- solution; if it did, the denominator of the rational solution would divide the numerator. If it didn't, the equation\n-- would have no solutions in the integers.\n\nIsSolutionZ: (a: ZZ) -> (b: ZZ) -> (c: ZZ) -> (a0: NotZero a) -> Either (ZZPair) (ZZ)\nIsSolutionZ a b c a0 = case (SND (Eucl (absZ(c-b)) (absZ a) )) of\n Z => Right ((NatToZZ(FST (Eucl (absZ(c-b)) (absZ a) )))*(findSignDiff c b))\n (S k) => Left((c-b),a)\n\n-}\n\n-- some helper functions for the DiophantineProof\n\nhelper5: (quot: ZZ) -> (a: ZZ) -> (quot*a=a*quot)\nhelper5 quot a = multCommutativeZ (quot) (a)\n\nhelper6: (a: ZZ) -> (b: ZZ) -> (c: ZZ) -> (quot: ZZ) -> (c-b=quot*a) -> (c-b=a*quot)\nhelper6 a b c quot prf = trans (prf) (helper5 (quot) (a))\n\nhelper7: (a: ZZ) -> (b: ZZ) -> (c: ZZ) -> (quot: ZZ) -> (c-b=a*quot) -> ((c-b+b)=a*quot+b)\nhelper7 a b c quot prf = ApZZ (\\x => x+ b) (prf)\n\nhelper8: (b: ZZ) -> (-b+b=0)\nhelper8 b = plusNegateInverseRZ b\n\nhelper10: (c: ZZ) -> (b: ZZ) -> ((c-b)+b=c)\nhelper10 c b = rewrite sym (plusAssociativeZ (c) (-b) (b)) in\n rewrite plusNegateInverseRZ (b) in\n rewrite plusZeroRightNeutralZ c in\n Refl\n\nhelper11: (a: ZZ) -> (b: ZZ) -> (c: ZZ) -> (quot: ZZ) -> (c-b=a*quot) -> (c=a*quot+b)\nhelper11 a b c quot prf = trans (sym (helper10 c b)) (helper7 a b c quot prf)\n\n-- If a Diophantine equation has a solution, this generates the proof.\n\nDiophantineProof: (a: ZZ) -> (b: ZZ) -> (c: ZZ) -> (quot: ZZ) -> (c-b=quot*a) -> ((a*quot+b=c))\nDiophantineProof a b c quot x = sym (helper11 (a) (b) (c) (quot) (helper6 a b c quot x))\n\n--This solves the equation ax+b=c and if it has an integer solution, it generates the solution with proof.\n\nDiophantineSolver: (a: ZZ) -> (b: ZZ) -> (c: ZZ) -> (a0: NotZero a)\n-> Either (x: ZZ ** (a*x+b=c)) (x : ZZPair ** ( (SolExists, a*(fst x) + b*(snd x) = (snd x)*c), (NotZero (snd x))) )\nDiophantineSolver a b c a0 = case (CheckIsQuotientZ (c-b) (a) a0) of\n (Left l) => Left ((fst l) ** (DiophantineProof a b c (fst l) (snd l)))\n (Right r) => Right (GeneralEqSolver a b c (a0))\n\n -- Now, for 2 variable Diophantine equations\n\n||| The solution of the homogeneous equation ax + by =0 is any integer multiple of (-b,a)\nhomogeneous: (a: ZZ) -> (b: ZZ) -> (k: ZZ) -> ((a*(k*(-b))+b*(k*a))=0)\nhomogeneous a b k = rewrite (multAssociativeZ (a) (k) (-b)) in\n rewrite (multCommutativeZ (a) (k)) in\n rewrite (multAssociativeZ (b) (k) (a)) in\n rewrite (multCommutativeZ (b) (k)) in\n rewrite sym (multAssociativeZ (k) (a) (-b)) in\n rewrite sym (multAssociativeZ (k) (b) (a)) in\n rewrite sym (multDistributesOverPlusRightZ k (a*(-b)) (b*a)) in\n rewrite (SolutionProof (a) (b)) in\n rewrite multZeroRightZeroZ k in\n Refl\n", "meta": {"hexsha": "d2c0625a4cf4dc46babed466e321f010692d810c", "size": 8054, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Code/Linear.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/Linear.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/Linear.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.9479166667, "max_line_length": 158, "alphanum_fraction": 0.5679165632, "num_tokens": 2918, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7956581000631542, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.5563674540937226}}
{"text": "= Tactics : More Basic Tactics\n\nThis chapter introduces several additional proof strategies and tactics that\nallow us to begin proving more interesting properties of functional programs. We\nwill see:\n\n - how to use auxiliary lemmas in both \"forward-style\" and \"backward-style\"\n proofs;\n\n - how to reason about data constructors (in particular, how to use the fact\n that they are injective and disjoint);\n\n - how to strengthen an induction hypothesis (and when such strengthening is\n required); and\n\n - more details on how to reason by case analysis.\n\n> module Tactics\n>\n> import Basics\n> import Induction\n\n> import Pruviloj\n>\n> %access public export\n>\n> %default total\n>\n> %language ElabReflection\n>\n\n\n== The \\idr{exact} Tactic\n\nWe often encounter situations where the goal to be proved is _exactly_ the same\nas some hypothesis in the context or some previously proved lemma.\n\n> silly1 : (n, m, o, p : Nat) -> (n = m) -> [n,o] = [n,p] -> [n,o] = [m,p]\n\nHere, we could prove this with rewrites:\n\n> silly1 n m o p eq1 eq2 = rewrite eq2 in\n> rewrite eq1 in Refl\n\nor the dependent pattern matching:\n\n```idris\nsilly1 n n o o Refl Refl = Refl\n```\n\n\\todo[inline]{Write more about dependent pattern matching techinque. Maybe move\nto an earlier chapter?}\n\nas we have done several times before. We can achieve the same effect by a series\nof tactic applications, using \\idr{exact} instead of the\n\\idr{rewrite}+\\idr{Refl} combination:\n\n\\todo[inline]{Explain \\idr{intros} (move text from `Basics`?), \\idr{Var} and\n\\idr{rewriteWith}. Explain the \"backwards\" order.}\n\n\\todo[inline]{\\idr{| _ => fail []} is needed for totality}\n\n> silly1' : (n, m, o, p : Nat) -> (n = m) -> [n,o] = [n,p] -> [n,o] = [m,p]\n> silly1' = %runElab silly1_tac\n> where\n> silly1_tac : Elab ()\n> silly1_tac = do\n> [n,m,o,p,eq1,eq2] <- intros\n> | _ => fail []\n> rewriteWith $ Var eq1\n> exact $ Var eq2\n\n(This tactic is called `apply` in Coq.)\n\n\\todo[inline]{The following doesn't seem to hold in Idris, you have to manually\napply things with \\idr{RApp} for \\idr{exact} to work. Maybe there's another\ntactic?}\n\nThe \\idr{exact} tactic also works with _conditional_ hypotheses and lemmas: if the\nstatement being applied is an implication, then the premises of this implication\nwill be added to the list of subgoals needing to be proved.\n\n\n> silly2 : (n, m, o, p : Nat) -> (n = m) ->\n> ((q, r : Nat) -> q = r -> [q,o] = [r,p]) ->\n> [n,o] = [m,p]\n> silly2 = %runElab silly2_tac\n> where\n> silly2_tac : Elab ()\n> silly2_tac = do\n> [n,m,o,p,eq1,eq2] <- intros\n> | _ => fail []\n> exact $ (((Var eq2) `RApp` (Var n)) `RApp` (Var m)) `RApp` (Var eq1)\n\nYou may find it instructive to experiment with this proof and see if there is a\nway to complete it using just \\idr{rewrite} instead of \\idr{exact}.\n\n\\todo[inline]{Edit}\n\nTypically, when we use \\idr{exact h}, the statement \\idr{h} will begin with a\n`(...)` that binds some _universal variables_. When Idris matches the current\ngoal against the conclusion of \\idr{h}, it will try to find appropriate values\nfor these variables. For example, when we do \\idr{exact $ Var eq2} in the\nfollowing proof, the universal variable \\idr{q} in \\idr{eq2} gets instantiated\nwith \\idr{n} and \\idr{r} gets instantiated with \\idr{m}.\n\n\n> silly2a : (n, m : Nat) -> (n,n) = (m,m) ->\n> ((q, r : Nat) -> (q,q) = (r,r) -> [q] = [r]) ->\n> [n] = [m]\n> silly2a = %runElab silly2a_tac\n> where\n> silly2a_tac : Elab ()\n> silly2a_tac = do\n> [n,m,eq1,eq2] <- intros\n> | _ => fail []\n> exact $ (((Var eq2) `RApp` (Var n)) `RApp` (Var m)) `RApp` (Var eq1)\n\n\n==== Exercise: 2 stars, optional (silly_ex)\n\nComplete the following proof without using `simpl`.\n\n> silly_ex : ((n : Nat) -> evenb n = True -> oddb (S n) = True)\n> -> evenb 3 = True -> oddb 4 = True\n> silly_ex = ?remove_me -- %runElab silly_ex_tac\n> where\n> silly_ex_tac : Elab ()\n> silly_ex_tac = ?silly_ex_tac_rhs\n\n$\\square$\n\nTo use the \\idr{exact} tactic, the (conclusion of the) fact being applied must\nmatch the goal exactly -- for example, \\idr{exact} will not work if the left and\nright sides of the equality are swapped.\n\n> silly3_firsttry : (n : Nat) -> True = n == 5 ->\n> (S (S n)) == 7 = True\n> silly3_firsttry = %runElab silly3_firsttry_tac\n> where\n> silly3_firsttry_tac : Elab ()\n> silly3_firsttry_tac = do\n> [_,h] <- intros\n> | _ => fail []\n\nHere we cannot use \\idr{exact} directly, but we can use the \\idr{symmetry}\ntactic, which switches the left and right sides of an equality in the goal.\n\n> symmetry\n> exact $ Var h\n\n\n==== Exercise: 3 stars (apply_exercise1)\n\n(_Hint_: You can use \\idr{exact} with previously defined lemmas, not just\nhypotheses in the context. Remember that `:search` is your friend.)\n\n> rev : (l : List x) -> List x\n> rev [] = []\n> rev (h::t) = (rev t) ++ [h]\n\n> rev_exercise1 : (l, l' : List Nat) -> l = rev l' -> l' = rev l\n> rev_exercise1 = ?remove_me1 -- %runElab rev_exercise1_tac\n> where\n> rev_exercise1_tac : Elab ()\n> rev_exercise1_tac = ?rev_exercise1_tac_rhs\n\n$\\square$\n\n\n==== Exercise: 1 star, optional (apply_rewrite)\n\nBriefly explain the difference between the tactics \\idr{exact} and\n\\idr{rewriteWith}. What are the situations where both can usefully be applied?\n\n> -- FILL IN HERE\n\n$\\square$\n\n\n== The \\idr{apply} Tactic\n\nThe following silly example uses two rewrites in a row to get from `[a,b]` to\n`[e,f]`.\n\n> trans_eq_example : (a, b, c, d, e, f : Nat) ->\n> [a,b] = [c,d] -> [c,d] = [e,f] -> [a,b] = [e,f]\n> trans_eq_example a b c d e f eq1 eq2 = rewrite eq1 in\n> rewrite eq2 in Refl\n\nNote that this can also be proven with dependent pattern matching:\n\n```idris\ntrans_eq_example a b a b a b Refl Refl = Refl\n```\n\nSince this is a common pattern, we might like to pull it out as a lemma\nrecording, once and for all, the fact that equality is transitive.\n\n> trans_eq : (n, m, o : x) -> n = m -> m = o -> n = o\n> trans_eq n n n Refl Refl = Refl\n\n(This lemma already exists in Idris' stdlib under the name of \\idr{trans}.)\n\nNow, we should be able to use \\idr{trans_eq} to prove the above example.\nHowever, to do this we need a slight refinement of the \\idr{exact} tactic.\n\n> trans_eq_example' : (a, b, c, d, e, f : Nat) ->\n> [a,b] = [c,d] -> [c,d] = [e,f] -> [a,b] = [e,f]\n> trans_eq_example' = %runElab trans_eq_example_tac\n> where\n> trans_eq_example_tac : Elab ()\n> trans_eq_example_tac = do\n> [a,b,c,d,e,f,eq1,eq2] <- intros\n> | _ => fail []\n\n\\todo[inline]{Edit: Idris apparently can figure things out itself via\n\\idr{solve}. Explain the quotation syntax.}\n\nIf we simply tell Idris \\idr{apply (Var `{trans_eq}) ..} at this point, it can\ntell (by matching the goal against the conclusion of the lemma) that it should\ninstantiate \\idr{x} with \\idr{[Nat]}, \\idr{n} with \\idr{[a,b]}, and \\idr{o} with\n\\idr{[e,f]}. However, the matching process doesn't determine an instantiation\nfor \\idr{m}: we have to supply one explicitly by adding with (m:=[c,d]) to the\ninvocation of \\idr{apply}.\n\n> [_,_,_,_,_,_] <- apply (Var `{trans_eq})\n> [True, True, True, True, False, False]\n> | _ => fail []\n> solve\n> exact $ Var eq1\n> exact $ Var eq2\n\n\n==== Exercise: 3 stars, optional (apply_with_exercise)\n\n> trans_eq_exercise : (n, m, o, p : Nat) ->\n> m = (minusTwo o) ->\n> (n + p) = m ->\n> (n + p) = (minusTwo o)\n> trans_eq_exercise = ?remove_me2 -- %runElab trans_eq_exercise_tac\n> where\n> trans_eq_exercise_tac : Elab ()\n> trans_eq_exercise_tac = ?trans_eq_exercise_rhs\n\n$\\square$\n\n\n== The \\idr{inversion} Tactic\n\nRecall the definition of natural numbers:\n\n```idris\n data Nat : Type where\n Z : Nat\n S : Nat -> Nat\n```\n\nIt is obvious from this definition that every number has one of two forms:\neither it is the constructor \\idr{Z} or it is built by applying the constructor\n\\idr{S} to another number. But there is more here than meets the eye: implicit\nin the definition (and in our informal understanding of how datatype\ndeclarations work in other programming languages) are two more facts:\n\n - The constructor \\idr{S} is _injective_. That is, if \\idr{S n = S m}, it must\n be the case that \\idr{n = m}.\n\n - The constructors \\idr{Z} and \\idr{S} are _disjoint_. That is, \\idr{Z} is not\n equal to \\idr{S n} for any \\idr{n}.\n\nSimilar principles apply to all inductively defined types: all constructors are\ninjective, and the values built from distinct constructors are never equal. For\nlists, the \\idr{(::)} constructor is injective and \\idr{Nil} is different from\nevery non-empty list. For booleans, \\idr{True} and \\idr{False} are different.\n(Since neither \\idr{True} nor \\idr{False} take any arguments, their injectivity\nis not interesting.) And so on.\n\nIdris provides a tactic called \\idr{injective} that allows us to exploit these\nprinciples in proofs. To see how to use it, let's show explicitly that the\n\\idr{S} constructor is injective:\n\n> S_injective : (n, m : Nat) -> S n = S m -> n = m\n> S_injective = %runElab S_injective_tac\n> where\n> covering\n> S_injective_tac : Elab ()\n> S_injective_tac = do\n> [n, m, h] <- intros\n> | _ => fail []\n\nBy writing \\idr{injective (Var h) res} at this point, we are asking Idris to\ngenerate all equations that it can infer from \\idr{h} as additional hypotheses,\nreplacing variables in the goal as it goes. In the present example, this amounts\nto adding a new hypothesis \\idr{h1 : n = m} and replacing \\idr{n} by \\idr{m} in\nthe goal.\n\n\\todo[inline]{Explain \\idr{gensym}, \\idr{unproduct} and \\idr{hypothesis}}\n\n> res <- gensym \"sInj\"\n> injective (Var h) res\n> unproduct (Var res)\n> hypothesis\n\nHere's a more interesting example that shows how multiple equations can be\nderived at once.\n\n\\todo[inline]{Works quite fast in Elab shell but hangs the compiler}\n\n> -- inversion_ex1 : (n, m, o : Nat) -> [n, m] = [o, o] -> [n] = [m]\n> -- inversion_ex1 = %runElab inversion_ex1_tac\n> -- where\n> -- inversion_ex1_tac : Elab ()\n> -- inversion_ex1_tac = do\n> -- [n, m, o, eq] <- intros\n> -- | _ => fail []\n> -- eqinj <- gensym \"eqinj\"\n> -- injective (Var eq) eqinj\n> --\n> -- eqinj2 <- gensym \"eqinj2\" -- manual destructuring\n> -- both (Var eqinj) !(gensym \"natnat\") eqinj2\n> -- neqo <- gensym \"neqo\"\n> -- eqinj3 <- gensym \"eqinj3\"\n> -- both (Var eqinj2) no eqinj3\n> -- meqos <- gensym \"meqos\"\n> -- both (Var eqinj3) mos !(gensym \"uu\")\n> --\n> -- oeqn <- gensym \"oeqn\"\n> -- symmetryAs (Var neqo) oeqn\n> -- symmetry\n> -- rewriteWith $ Var oeqn\n> -- exact $ Var meqos\n> -- solve\n\nNote that we need to pass the parameter \\idr{eqinj} which will be bound to\nequations that \\idr{injective} generates.\n\n\\todo[inline]{Remove when a release with\nhttps://github.com/idris-lang/Idris-dev/pull/3925 happens}\n\n==== Exercise: 1 star (inversion_ex3)\n\n> inversion_ex3 : (x, y, z : a) -> (l, j : List a) ->\n> x :: y :: l = z :: j ->\n> y :: l = x :: j ->\n> x = y\n> inversion_ex3 = ?remove_me3 -- %runElab inversion_ex3_tac\n> where\n> inversion_ex3_tac : Elab ()\n> inversion_ex3_tac = ?inversion_ex3_tac_rhs\n\n$\\square$\n\n\\todo[inline]{Edit}\n\nWhen used on a hypothesis involving an equality between _different_ constructors\n(e.g., \\idr{S n = Z}), \\idr{injective} solves the goal immediately. Consider the\nfollowing proof:\n\n> beq_nat_0_l : Z == n = True -> n = Z\n\nWe can proceed by case analysis on n. The first case is trivial.\n\n> beq_nat_0_l {n=Z} _ = Refl\n\nHowever, the second one doesn't look so simple: assuming \\idr{0 == S n' = True},\nwe must show \\idr{S n' = 0}, but the latter clearly contradictory! The way\nforward lies in the assumption. After simplifying the goal state, we see that\n\\idr{0 == S n' = True} has become \\idr{False = True}:\n\n\\todo[inline]{How to show impossible cases from Elab?}\n\n> beq_nat_0_l {n=(S _)} prf = absurd prf\n\nIf we use \\idr{absurd} on this hypothesis, Idris allows us to safely infer any\nconclusion from it, in this case our goal of \\idr{n = 0}.\n\nThis is an instance of a logical principle known as the principle of explosion,\nwhich asserts that a contradictory hypothesis entails anything, even false\nthings!\n\n> inversion_ex4 : (n : Nat) -> S n = Z -> 2 + 2 = 5\n> -- we need \"sym\" because Prelude.Nat only disproves \"Z = S n\" for us\n> inversion_ex4 n prf = absurd $ sym prf\n\nIn simple cases like this, we could've also solved this with matching on\n\\idr{prf}:\n\n```idris\ninversion_ex4 _ Refl impossible\n```\n\n> inversion_ex5 : (n, m : Nat) -> False = True -> [n] = [m]\n> inversion_ex5 n m prf = absurd prf\n\nAgain, here we can also write\n\n```idris\ninversion_ex5 _ _ Refl impossible\n```\n\nIf you find the principle of explosion confusing, remember that these proofs are\nnot actually showing that the conclusion of the statement holds. Rather, they\nare arguing that, if the nonsensical situation described by the premise did\nsomehow arise, then the nonsensical conclusion would follow. We'll explore the\nprinciple of explosion of more detail in the next chapter.\n\n\n==== Exercise: 1 star (inversion_ex6)\n\n> inversion_ex6 : (x, y, z : a) -> (l, j : List a) ->\n> x :: y :: l = [] ->\n> y :: l = z :: j ->\n> x = z\n> inversion_ex6 x y z l j prf prf1 = ?inversion_ex6_rhs\n\n$\\square$\n\nTo summarize this discussion, suppose \\idr{h} is a hypothesis in the context\nor a previously proven lemma of the form\n\n \\idr{c a1 a2 ... an = d b1 b2 ... bm}\n\n\\todo[inline]{Edit, especially the \\idr{disjoint} part}\n\nfor some constructors \\idr{c} and \\idr{d} and arguments \\idr{a1 ... an} and\n\\idr{b1 ... bm}. Then \\idr{injective h} and \\idr{disjoint h} have the following\neffects:\n\n - If \\idr{c} and \\idr{d} are the same constructor, then, by the injectivity of\n this constructor, we know that \\idr{a1 = b1}, \\idr{a2 = b2}, etc. The\n \\idr{injective h} adds these facts to the context and tries to use them to\n rewrite the goal.\n\n - If \\idr{c} and \\idr{d} are different constructors, then the hypothesis\n \\idr{h} is contradictory, and the current goal doesn't have to be considered\n at all. In this case, \\idr{disjoint h} marks the current goal as completed\n and pops it off the goal stack.\n\nThe injectivity of constructors allows us to reason that \\idr{(n, m : Nat) -> S\nn = S m -> n = m}. The converse of this implication is an instance of a more\ngeneral fact about both constructors and functions, which we will find useful in\na few places below:\n\n> f_equal : (f : a -> b) -> (x, y : a) -> x = y -> f x = f y\n> f_equal f x x Refl = Refl\n\n(This is called \\idr{cong} in Idris' stdlib.)\n\n\n== Using Tactics on Hypotheses\n\n\\todo[inline]{Edit, Idris runs \\idr{compute} on hypotheses automatically}\n\nBy default, most tactics work on the goal formula and leave the context\nunchanged. However, most tactics also have a variant that performs a similar\noperation on a statement in the context. For example, the tactic \\idr{compute}\nin H performs simplification in the hypothesis named \\idr{h} in the context.\n\n> S_inj : (n, m : Nat) -> (b : Bool) ->\n> S n == S m = b -> n == m = b\n> S_inj = %runElab S_inj_tac\n> where\n> S_inj_tac : Elab ()\n> S_inj_tac = do\n> [n, m, b, eq] <- intros\n> | _ => fail []\n> exact $ Var eq\n\n\\todo[inline]{Edit}\n\nSimilarly, \\idr{applyIn l h} matches some conditional statement \\idr{l} (of the\nform \\idr{l1 -> l2}, say) against a hypothesis \\idr{h} in the context. However,\nunlike ordinary \\idr{exact} (which rewrites a goal matching \\idr{l2} into a\nsubgoal \\idr{l1}), \\idr{applyIn l h n} matches \\idr{h} against \\idr{l1} and, if\nsuccessful, binds the result \\idr{l2} to \\idr{n}.\n\nIn other words, \\idr{applyIn l h} gives us a form of \"forward reasoning\": from\n\\idr{l1 -> l2} and a hypothesis matching \\idr{l1}, it produces a hypothesis\nmatching \\idr{l2}. By contrast, \\idr{exact l} is \"backward reasoning\": it says\nthat if we know \\idr{l1->l2} and we are trying to prove \\idr{l2}, it suffices to\nprove \\idr{l1}.\n\nHere is a variant of a proof from above, using forward reasoning throughout\ninstead of backward reasoning.\n\n> silly3' : (n, m : Nat) -> (n == 5 = True -> m == 7 = True) ->\n> True = n == 5 -> True = m == 7\n> silly3' = %runElab silly3_tac\n> where\n> silly3_tac : Elab ()\n> silly3_tac = do\n> [n,m,eq,h] <- intros\n> | _ => fail []\n> hsym <- symmetryAs (Var h) \"hsym\"\n> happ <- applyAs (Var eq) (Var hsym) \"happ\"\n> happsym <- symmetryAs (Var happ) \"happsym\"\n> exact $ Var happsym\n\nForward reasoning starts from what is _given_ (premises, previously proven\ntheorems) and iteratively draws conclusions from them until the goal is reached.\nBackward reasoning starts from the _goal_, and iteratively reasons about what\nwould imply the goal, until premises or previously proven theorems are reached.\nIf you've seen informal proofs before (for example, in a math or computer\nscience class), they probably used forward reasoning. In general, idiomatic use\nof Idris elab scripts tends to favor backward reasoning, but in some situations\nthe forward style can be easier to think about.\n\n\n==== Exercise: 3 stars, recommended (plus_n_n_injective)\n\nPractice using \"in\" variants in this exercise. (Hint: use \\idr{plus_n_Sm}.)\n\n> plus_n_n_injective : n + n = m + m -> n = m\n> plus_n_n_injective = ?plus_n_n_injective_rhs\n\n$\\square$\n\n\n== Varying the Induction Hypothesis\n\nSometimes it is important to control the exact form of the induction hypothesis\nwhen carrying out inductive proofs in Idris elab script. In particular, we need\nto be careful about which of the assumptions we move (using \\idr{intros}) from\nthe goal to the context before invoking the \\idr{induction} tactic. For example,\nsuppose we want to show that the \\idr{double} function is injective -- i.e., that\nit maps different arguments to different results:\n\n> double_injective : double n = double m -> n = m\n> double_injective {n=Z} {m=Z} _ = Refl\n> double_injective {n=Z} {m=(S _)} Refl impossible\n> double_injective {n=(S _)} {m=Z} Refl impossible\n> double_injective {n=(S n')} {m=(S m')} eq =\n> let eqss = succInjective _ _ $ succInjective _ _ eq\n> in rewrite double_injective {n=n'} {m=m'} eqss in Refl\n\n\\todo[inline]{Edit the rest of the section to use \\idr{induction}?}\n\nThe way we _start_ this proof is a bit delicate: if we begin with\n\n intros n. induction n.\n\nall is well. But if we begin it with\n\n intros n m. induction n.\n\nwe get stuck in the middle of the inductive case...\n\nTheorem double_injective_FAILED : ∀n m,\n double n = double m -> n = m.\nProof.\n intros n m. induction n as [| n']. - (* n = Z *) simpl. intros eq. destruct m\n as [| m'].\n + (* m = Z *) reflexivity. + (* m = S m' *) inversion eq.\n - (* n = S n' *) intros eq. destruct m as [| m'].\n + (* m = Z *) inversion eq. + (* m = S m' *) apply f_equal.\n\nAt this point, the induction hypothesis, IHn', does not give us n' = m' -- there\nis an extra S in the way -- so the goal is not provable.\n\n Abort.\n\nWhat went wrong?\n\nThe problem is that, at the point we invoke the induction hypothesis, we have\nalready introduced m into the context -- intuitively, we have told Coq, \"Let's\nconsider some particular n and m...\" and we now have to prove that, if double n\n= double m for these particular n and m, then n = m.\n\nThe next tactic, induction n says to Coq: We are going to show the goal by\ninduction on n. That is, we are going to prove, for all n, that the proposition\n\n - P n = \"if double n = double m, then n = m\"\n\nholds, by showing\n\n - P Z\n (i.e., \"if double Z = double m then Z = m\") and\n\n - P n -> P (S n)\n (i.e., \"if double n = double m then n = m\" implies \"if double (S n) = double\n m then S n = m\").\n\nIf we look closely at the second statement, it is saying something rather\nstrange: it says that, for a particular m, if we know\n\n - \"if double n = double m then n = m\"\n\nthen we can prove\n\n - \"if double (S n) = double m then S n = m\".\n\nTo see why this is strange, let's think of a particular m -- say, 5. The\nstatement is then saying that, if we know\n\n - Q = \"if double n = 10 then n = 5\"\n\nthen we can prove\n\n - R = \"if double (S n) = 10 then S n = 5\".\n\nBut knowing Q doesn't give us any help at all with proving R! (If we tried to\nprove R from Q, we would start with something like \"Suppose double (S n) =\n10...\" but then we'd be stuck: knowing that double (S n) is 10 tells us nothing\nabout whether double n is 10, so Q is useless.)\n\nTrying to carry out this proof by induction on n when m is already in the\ncontext doesn't work because we are then trying to prove a relation involving\nevery n but just a single m.\n\nThe successful proof of double_injective leaves m in the goal statement at the\npoint where the induction tactic is invoked on n:\n\nTheorem double_injective : ∀n m,\n double n = double m -> n = m.\nProof.\n intros n. induction n as [| n']. - (* n = Z *) simpl. intros m eq. destruct m\n as [| m'].\n + (* m = Z *) reflexivity. + (* m = S m' *) inversion eq.\n\n - (* n = S n' *) simpl.\n\nNotice that both the goal and the induction hypothesis are different this time:\nthe goal asks us to prove something more general (i.e., to prove the statement\nfor every m), but the IH is correspondingly more flexible, allowing us to choose\nany m we like when we apply the IH.\n\n intros m eq.\n\nNow we've chosen a particular m and introduced the assumption that double n =\ndouble m. Since we are doing a case analysis on n, we also need a case analysis\non m to keep the two \"in sync.\"\n\n destruct m as [| m']. + (* m = Z *) simpl.\n\nThe 0 case is trivial:\n\n inversion eq.\n\n + (* m = S m' *)\n apply f_equal.\n\nAt this point, since we are in the second branch of the destruct m, the m'\nmentioned in the context is the predecessor of the m we started out talking\nabout. Since we are also in the S branch of the induction, this is perfect: if\nwe instantiate the generic m in the IH with the current m' (this instantiation\nis performed automatically by the apply in the next step), then IHn' gives us\nexactly what we need to finish the proof.\n\n apply IHn'. inversion eq. reflexivity. Qed.\n\nWhat you should take away from all this is that we need to be careful about\nusing induction to try to prove something too specific: To prove a property of n\nand m by induction on n, it is sometimes important to leave m generic.\n\nThe following exercise requires the same pattern.\n\n\n==== Exercise: 2 stars (beq_nat_true)\n\n\\ \\todo[inline]{We explicitly write out implicits as having type \\idr{Nat} since\n\\idr{(==)} is polymorphic}\n\n> beq_nat_true : {n, m : Nat} -> n == m = True -> n = m\n> beq_nat_true prf = ?beq_nat_true_rhs\n\n$\\square$\n\n\n==== Exercise: 2 stars, advanced (beq_nat_true_informal)\n\nGive a careful informal proof of \\idr{beq_nat_true}, being as explicit as possible\nabout quantifiers.\n\n> -- FILL IN HERE\n\n$\\square$\n\n\\todo[inline]{What to do with the rest of this?}\n\nThe strategy of doing fewer intros before an induction to obtain a more general\nIH doesn't always work by itself; sometimes some rearrangement of quantified\nvariables is needed. Suppose, for example, that we wanted to prove\ndouble_injective by induction on m instead of n.\n\nTheorem double_injective_take2_FAILED : ∀n m,\n double n = double m -> n = m.\nProof.\n intros n m. induction m as [| m']. - (* m = Z *) simpl. intros eq. destruct n\n as [| n'].\n + (* n = Z *) reflexivity. + (* n = S n' *) inversion eq.\n - (* m = S m' *) intros eq. destruct n as [| n'].\n + (* n = Z *) inversion eq. + (* n = S n' *) apply f_equal.\n (* Stuck again here, just like before. *)\nAbort.\n\nThe problem is that, to do induction on m, we must first introduce n. (If we\nsimply say induction m without introducing anything first, Coq will\nautomatically introduce n for us!)\n\nWhat can we do about this? One possibility is to rewrite the statement of the\nlemma so that m is quantified before n. This works, but it's not nice: We don't\nwant to have to twist the statements of lemmas to fit the needs of a particular\nstrategy for proving them! Rather we want to state them in the clearest and most\nnatural way.\n\nWhat we can do instead is to first introduce all the quantified variables and\nthen re-generalize one or more of them, selectively taking variables out of the\ncontext and putting them back at the beginning of the goal. The generalize\ndependent tactic does this.\n\nTheorem double_injective_take2 : ∀n m,\n double n = double m -> n = m.\nProof.\n intros n m. (* n and m are both in the context *) generalize dependent n. (*\n Now n is back in the goal and we can do induction on\n m and get a sufficiently general IH. *)\n induction m as [| m']. - (* m = Z *) simpl. intros n eq. destruct n as [| n'].\n + (* n = Z *) reflexivity. + (* n = S n' *) inversion eq.\n - (* m = S m' *) intros n eq. destruct n as [| n'].\n + (* n = Z *) inversion eq. + (* n = S n' *) apply f_equal.\n apply IHm'. inversion eq. reflexivity. Qed.\n\nLet's look at an informal proof of this theorem. Note that the proposition we\nprove by induction leaves n quantified, corresponding to the use of generalize\ndependent in our formal proof.\n\n_Theorem_: For any nats n and m, if double n = double m, then n = m.\n\n_Proof_: Let m be a Nat. We prove by induction on m that, for any n, if double n\n= double m then n = m.\n\n - First, suppose m = 0, and suppose n is a number such that double n = double\n m. We must show that n = 0.\n\n Since m = 0, by the definition of double we have double n = 0. There are two\n cases to consider for n. If n = 0 we are done, since m = 0 = n, as required.\n Otherwise, if n = S n' for some n', we derive a contradiction: by the\n definition of double, we can calculate double n = S (S (double n')), but\n this contradicts the assumption that double n = 0.\n\n - Second, suppose m = S m' and that n is again a number such that double n =\n double m. We must show that n = S m', with the induction hypothesis that for\n every number s, if double s = double m' then s = m'.\n\n By the fact that m = S m' and the definition of double, we have double n = S\n (S (double m')). There are two cases to consider for n.\n\n If n = 0, then by definition double n = 0, a contradiction.\n\n Thus, we may assume that n = S n' for some n', and again by the definition\n of double we have S (S (double n')) = S (S (double m')), which implies by\n inversion that double n' = double m'. Instantiating the induction hypothesis\n with n' thus allows us to conclude that n' = m', and it follows immediately\n that S n' = S m'. Since S n' = n and S m' = m, this is just what we wanted\n to show. $\\square$\n\nBefore we close this section and move on to some exercises, let's digress\nbriefly and use \\idr{beq_nat_true} to prove a similar property of identifiers\nthat we'll need in later chapters:\n\n> data Id : Type where\n> MkId : Nat -> Id\n\n> beq_id : (x1, x2 : Id) -> Bool\n> beq_id (MkId n1) (MkId n2) = n1 == n2\n\n> beq_id_true : beq_id x y = True -> x = y\n> beq_id_true {x=MkId x'} {y=MkId y'} prf =\n> rewrite beq_nat_true {n=x'} {m=y'} prf in Refl\n\n\n=== Exercise: 3 stars, recommended (gen_dep_practice)\n\nProve this by induction on \\idr{l}.\n\n> data Option : (x : Type) -> Type where\n> Some : x -> Option x\n> None : Option x\n\n> nth_error : (l : List x) -> (n : Nat) -> Option x\n> nth_error [] n = None\n> nth_error (a::l') n = if n == 0\n> then Some a\n> else nth_error l' (Nat.pred n)\n\n> nth_error_after_last: (n : Nat) -> (l : List x) ->\n> length l = n -> nth_error l n = None\n\n$\\square$\n\n\n== Unfolding Definitions\n\n\\todo[inline]{Edit}\n\nIt sometimes happens that we need to manually unfold a definition so that we can\nmanipulate its right-hand side. For example, if we define...\n\n> square : Nat -> Nat\n> square n = n * n\n\n... and try to prove a simple fact about square...\n\n> square_mult : (n, m : Nat) -> square (n * m) = square n * square m\n> square_mult n m = rewrite multAssociative (n*m) n m in\n> rewrite multCommutative (n*m) n in\n> rewrite multAssociative (n*n) m m in\n> rewrite multAssociative n n m in Refl\n\n... we succeed because Idris unfolds everything for us automatically.\n\n\\todo[inline]{Remove the next part?}\n\n... we get stuck: simpl doesn't simplify anything at this point, and since we\nhaven't proved any other facts about square, there is nothing we can apply or\nrewrite with.\n\nTo make progress, we can manually unfold the definition of square:\n\n unfold square.\n\nNow we have plenty to work with: both sides of the equality are expressions\ninvolving multiplication, and we have lots of facts about multiplication at our\ndisposal. In particular, we know that it is commutative and associative, and\nfrom these facts it is not hard to finish the proof.\n\n rewrite mult_assoc. assert (H : n * m * n = n * n * m). { rewrite mult_comm.\n apply mult_assoc. } rewrite H. rewrite mult_assoc. reflexivity.\nQed.\n\nAt this point, a deeper discussion of unfolding and simplification is in order.\n\nYou may already have observed that \\idr{Refl} will often unfold the definitions\nof functions automatically when this allows them to make progress. For example,\nif we define \\idr{foo m} to be the constant \\idr{5}...\n\n> foo : Nat -> Nat\n> foo x = 5\n\nthen \\idr{Refl} in the following proof will unfold \\idr{foo m} to \\idr{(\\x => 5)\nm} and then further simplify this expression to just \\idr{5}.\n\n> silly_fact_1 : foo m + 1 = foo (m + 1) + 1\n> silly_fact_1 = Refl\n\nHowever, this automatic unfolding is rather conservative. For example, if we\ndefine a slightly more complicated function involving a pattern match...\n\n> bar : Nat -> Nat\n> bar Z = 5\n> bar (S _) = 5\n\n...then the analogous proof will get stuck:\n\n```idris\nsilly_fact_2_FAILED : bar m + 1 = bar (m + 1) + 1\nsilly_fact_2_FAILED = Refl\n```\n\nThe reason that \\idr{Refl} doesn't make progress here is that it notices that,\nafter tentatively unfolding \\idr{bar m}, it is left with a match whose\nscrutinee, \\idr{m}, is a variable, so the match cannot be simplified further.\n(It is not smart enough to notice that the two branches of the match are\nidentical.) So it gives up on unfolding \\idr{bar m} and leaves it alone.\nSimilarly, tentatively unfolding \\idr{bar (m+1)} leaves a match whose scrutinee\nis a function application (that, itself, cannot be simplified, even after\nunfolding the definition of \\idr{+}), so \\idr{Refl} leaves it alone.\n\nAt this point, there are two ways to make progress. One is to match on implicit\nparameter \\idr{m} to break the proof into two cases, each focusing on a more\nconcrete choice of \\idr{m} (\\idr{Z} vs \\idr{S _}). In each case, the match\ninside of \\idr{bar} can now make progress, and the proof is easy to complete.\n\n> silly_fact_2 : bar m + 1 = bar (m + 1) + 1\n> silly_fact_2 {m=Z} = Refl\n> silly_fact_2 {m=(S _)} = Refl\n\n\\todo[inline]{Edit}\n\nThis approach works, but it depends on our recognizing that the match hidden\ninside bar is what was preventing us from making progress. A more\nstraightforward way to make progress is to explicitly tell Idris to unfold bar.\n\n\\todo[inline]{Can we destruct in Elab script? Maybe with \\idr{deriveElim}?}\n\nFact silly_fact_2' : ∀m, bar m + 1 = bar (m + 1) + 1. Proof.\n intros m. unfold bar.\n\nNow it is apparent that we are stuck on the match expressions on both sides of\nthe =, and we can use destruct to finish the proof without thinking too hard.\n\n destruct m.\n - reflexivity.\n - reflexivity.\nQed.\n\n\n== Using \\idr{destruct} on Compound Expressions\n\n\\todo[inline]{Edit. Explain \\idr{with}}\n\nWe have seen many examples where destruct is used to perform case analysis of\nthe value of some variable. But sometimes we need to reason by cases on the\nresult of some _expression_. We can also do this with destruct.\n\nHere are some examples:\n\n> sillyfun : Nat -> Bool\n> sillyfun n = if n == 3\n> then False\n> else if n == 5\n> then False\n> else False\n\n> sillyfun_false : (n : Nat) -> sillyfun n = False\n> sillyfun_false n with (n == 3)\n> sillyfun_false n | True = Refl\n> sillyfun_false n | False with (n == 5)\n> sillyfun_false n | False | True = Refl\n> sillyfun_false n | False | False = Refl\n\n\nAfter unfolding \\idr{sillyfun} in the above proof, we find that we are stuck on\n\\idr{if (n == 3) then ... else ...}. But either \\idr{n} is equal to \\idr{3} or\nit isn't, so we can use \\idr{with (n == 3)} to let us reason about the two\ncases.\n\n\\todo[inline]{Edit}\n\nIn general, the destruct tactic can be used to perform case analysis of the\nresults of arbitrary computations. If e is an expression whose type is some\ninductively defined type T, then, for each constructor c of T, destruct e\ngenerates a subgoal in which all occurrences of e (in the goal and in the\ncontext) are replaced by c.\n\n\n==== Exercise: 3 stars, optional (combine_split)\n\n> combine_split : (l : List (x,y)) -> (l1 : List x) -> (l2 : List y) ->\n> unzip l = (l1, l2) -> zip l1 l2 = l\n> combine_split l l1 l2 prf = ?combine_split_rhs\n\n$\\square$\n\nHowever, destructing compound expressions requires a bit of care, as\nsuch destructs can sometimes erase information we need to complete a proof. For\nexample, suppose we define a function \\idr{sillyfun1} like this:\n\n> sillyfun1 : Nat -> Bool\n> sillyfun1 n = if n == 3\n> then True\n> else if n == 5\n> then True\n> else False\n\nNow suppose that we want to convince Idris of the (rather obvious) fact that\n\\idr{sillyfun1 n} yields \\idr{True} only when \\idr{n} is odd. By analogy with\nthe proofs we did with \\idr{sillyfun} above, it is natural to start the proof\nlike this:\n\n> sillyfun1_odd : (n : Nat) -> sillyfun1 n = True -> oddb n = True\n> sillyfun1_odd n prf with (n == 3) proof eq3\n> sillyfun1_odd n Refl | True =\n> rewrite beq_nat_true (sym eq3) {n} {m=3} in Refl\n> sillyfun1_odd n prf | False with (n == 5) proof eq5\n> sillyfun1_odd n Refl | False | True =\n> rewrite beq_nat_true (sym eq5) {n} {m=5} in Refl\n> sillyfun1_odd n prf | False | False = absurd prf\n\n\\todo[inline]{Edit the following, since \\idr{with} works fine here as well}\n\nWe get stuck at this point because the context does not contain enough\ninformation to prove the goal! The problem is that the substitution performed by\ndestruct is too brutal -- it threw away every occurrence of n == 3, but we need\nto keep some memory of this expression and how it was destructed, because we\nneed to be able to reason that, since n == 3 = True in this branch of the case\nanalysis, it must be that n = 3, from which it follows that n is odd.\n\nWhat we would really like is to substitute away all existing occurences of n ==\n3, but at the same time add an equation to the context that records which case\nwe are in. The eqn: qualifier allows us to introduce such an equation, giving it\na name that we choose.\n\nTheorem sillyfun1_odd : ∀(n : Nat),\n sillyfun1 n = True -> oddb n = True.\nProof.\n intros n eq. unfold sillyfun1 in eq. destruct (beq_nat n 3) eqn:Heqe3.\n (* Now\n we have the same state as at the point where we got\n stuck above, except that the context contains an extra equality assumption,\n which is exactly what we need to make progress. *) - (* e3 = True *) apply\n beq_nat_true in Heqe3. rewrite -> Heqe3. reflexivity. - (* e3 = False *) (*\n When we come to the second equality test in the body\n of the function we are reasoning about, we can use eqn: again in the\n same way, allow us to finish the proof. *)\n destruct (beq_nat n 5) eqn:Heqe5.\n + (* e5 = True *)\n apply beq_nat_true in Heqe5. rewrite -> Heqe5. reflexivity.\n + (* e5 = False *) inversion eq. Qed.\n\n\n==== Exercise: 2 stars (destruct_eqn_practice)\n\n> bool_fn_applied_thrice : (f : Bool -> Bool) -> (b : Bool) -> f (f (f b)) = f b\n> bool_fn_applied_thrice f b = ?bool_fn_applied_thrice_rhs\n\n$\\square$\n\n\n== Review\n\nWe've now seen many of Idris's most fundamental tactics. We'll introduce a few\nmore in the coming chapters, and later on we'll see some more powerful\nautomation tactics that make Idris help us with low-level details. But basically\nwe've got what we need to get work done.\n\nHere are the ones we've seen:\n\n\\todo[inline]{Edit}\n\n - \\idr{intros}: move hypotheses/variables from goal to context\n\n - \\idr{reflexivity}: finish the proof (when the goal looks like \\idr{e = e})\n\n - \\idr{exact}: prove goal using a hypothesis, lemma, or constructor\n\n - \\idr{apply... in H}: apply a hypothesis, lemma, or constructor to a\n hypothesis in the context (forward reasoning)\n\n - \\idr{apply... with...}: explicitly specify values for variables that cannot\n be determined by pattern matching\n\n - \\idr{compute}: simplify computations in the goal\n\n - \\idr{simpl in H}: ... or a hypothesis\n\n - \\idr{rewriteWith}: use an equality hypothesis (or lemma) to rewrite the goal\n\n - \\idr{rewrite ... in H}: ... or a hypothesis\n\n - \\idr{symmetry}: changes a goal of the form \\idr{t=u} into \\idr{u=t}\n\n - \\idr{symmetryAs h}: changes a hypothesis of the form \\idr{t=u} into\n \\idr{u=t}\n\n - \\idr{unfold}: replace a defined constant by its right-hand side in the goal\n\n - \\idr{unfold... in H}: ... or a hypothesis\n\n - \\idr{destruct... as...}: case analysis on values of inductively defined\n types\n\n - \\idr{destruct... eqn:...}: specify the name of an equation to be added to\n the context, recording the result of the case analysis\n\n - \\idr{induction... as...}: induction on values of inductively defined types\n\n - \\idr{injective}: reason by injectivity of constructors\n\n - \\idr{disjoint}: reason by distinctness of constructors\n\n - \\idr{assert (H: e)} (or \\idr{assert (e) as H}): introduce a \"local lemma\"\n \\idr{e} and call it \\idr{H}\n\n - \\idr{generalize dependent x}: move the variable \\idr{x} (and anything else\n that depends on it) from the context back to an explicit hypothesis in the goal formula\n\n\n== Additional Exercises\n\n\n==== Exercise: 3 stars (beq_nat_sym)\n\n> beq_nat_sym : (n, m : Nat) -> n == m = m == n\n> beq_nat_sym n m = ?beq_nat_sym_rhs\n\n$\\square$\n\n\n==== Exercise: 3 stars, advancedM? (beq_nat_sym_informal)\n\nGive an informal proof of this lemma that corresponds to your formal proof\nabove:\n\nTheorem: For any \\idr{Nat}s \\idr{n}, idr{m}, \\idr{n == m = m == n}\n\nProof:\n\n> --FILL IN HERE\n\n$\\square$\n\n\n==== Exercise: 3 stars, optional (beq_nat_trans)\n\n> beq_nat_trans : {n, m, p : Nat} -> n == m = True -> m == p = True ->\n> n == p = True\n> beq_nat_trans prf prf1 = ?beq_nat_trans_rhs\n\n$\\square$\n\n\n==== Exercise: 3 stars, advanced (split_combine)\n\nWe proved, in an exercise above, that for all lists of pairs, \\idr{zip} is the\ninverse of \\idr{unzip}. How would you formalize the statement that \\idr{unzip}\nis the inverse of \\idr{zip}? When is this property true?\n\nComplete the definition of \\idr{split_combine} below with a property that states\nthat \\idr{unzip} is the inverse of \\idr{zip}. Then, prove that the property\nholds. (Be sure to leave your induction hypothesis general by not doing\n\\idr{intros} on more things than necessary. Hint: what property do you need of\n\\idr{l1} and \\idr{l2} for \\idr{unzip (zip l1 l2) = (l1,l2)} to be true?)\n\n> split_combine : ?split_combine\n\n$\\square$\n\n\n==== Exercise: 3 stars, advanced (filter_exercise)\n\nThis one is a bit challenging. Pay attention to the form of your induction\nhypothesis.\n\n> filter_exercise : (test : a -> Bool) -> (x : a) -> (l, lf : List a) ->\n> filter test l = x :: lf ->\n> test x = True\n> filter_exercise test x l lf prf = ?filter_exercise_rhs\n\n$\\square$\n\n\n==== Exercise: 4 stars, advanced, recommended (forall_exists_challenge)\n\nDefine two recursive functions, \\idr{forallb} and \\idr{existsb}. The first\nchecks whether every element in a list satisfies a given predicate:\n\n \\idr{forallb oddb [1,3,5,7,9] = True}\n\n \\idr{forallb not [False,False] = True}\n\n \\idr{forallb evenb [0,2,4,5] = False}\n\n \\idr{forallb (== 5) [] = True}\n\nThe second checks whether there exists an element in the list that satisfies a\ngiven predicate:\n\n \\idr{existsb (== 5) [0,2,3,6] = False}\n\n \\idr{existsb ((&&) True) [True,True,False] = True}\n\n \\idr{existsb oddb [1,0,0,0,0,3] = True}\n\n \\idr{existsb evenb [] = False}\n\nNext, define a _nonrecursive_ version of \\idr{existsb} -- call it \\idr{existsb'}\n-- using \\idr{forallb} and \\idr{not}.\n\nFinally, prove a theorem \\idr{existsb_existsb'} stating that \\idr{existsb'} and\n\\idr{existsb} have the same behavior.\n\n> -- FILL IN HERE\n\n$\\square$\n", "meta": {"hexsha": "e29cee16bb833fff1a63b49bec43220314fc7635", "size": 40833, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "src/Tactics.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/Tactics.lidr", "max_issues_repo_name": "diseraluca/software-foundations", "max_issues_repo_head_hexsha": "03e178fc616e50019c4168fb488f67fbfb46fafa", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 91, "max_issues_repo_issues_event_min_datetime": "2019-11-11T15:41:26.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-21T04:17:18.000Z", "max_forks_repo_path": "src/Tactics.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": 35.0197255575, "max_line_length": 91, "alphanum_fraction": 0.670462616, "num_tokens": 12050, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6992544335934766, "lm_q2_score": 0.7956581000631542, "lm_q1q2_score": 0.5563674540937226}}
{"text": "data Tree elem = Empty\n | Node (Tree elem) elem (Tree elem)\n\nEq elem => Eq (Tree elem) where\n (==) Empty Empty = True\n (==) (Node left e right) (Node left' e' right')\n = left == left' && e == e' && right == right'\n (==) _ _ = False\n\nFunctor Tree where\n map f Empty = Empty\n map f (Node left e right)\n = Node (map f left)\n (f e)\n (map f right)\n\nFoldable Tree where\n foldr f acc Empty = acc\n foldr f acc (Node left e right) = let leftfold = foldr f acc left\n rightfold = foldr f leftfold right in\n f e rightfold\n\n null Empty = True\n null _ = False\n", "meta": {"hexsha": "2f838244cb6c7228641a116681ae38055c702ed0", "size": 701, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "tests/typedd-book/chapter07/Tree.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/typedd-book/chapter07/Tree.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/typedd-book/chapter07/Tree.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.04, "max_line_length": 77, "alphanum_fraction": 0.4950071327, "num_tokens": 186, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.78793120560257, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.5561100478798597}}
{"text": "module Main\n\n%default total\n\n-- An expensive function.\nqib : Nat -> Nat\nqib Z = 1\nqib (S Z) = 2\nqib (S (S n)) = qib n * qib (S n)\n\n-- An equality whose size reflects the size of numbers.\ndata Equals : Nat -> Nat -> Type where\n EqZ : Z `Equals` Z\n EqS : m `Equals` n -> S m `Equals` S n\n\neq_refl : {n : Nat} -> n `Equals` n\neq_refl {n = Z} = EqZ\neq_refl {n = S n} = EqS eq_refl\n\n-- Here, the proof is very expensive to compute.\n-- We add a recursive argument to prevent Idris from inlining the function.\nf : (r, n : Nat) -> Subset Nat (\\k => qib n `Equals` qib k)\nf Z n = Element n eq_refl\nf (S r) n = f r n\n\n-- A (contrived) relation, just to have something to show.\ndata Represents : Nat -> Nat -> Type where\n Axiom : (n : Nat) -> qib n `Represents` n\n\n-- Here, the witness is very expensive to compute.\n-- We add a recursive argument to prevent Idris from inlining the function.\ng : (r, n : Nat) -> Exists (\\k : Nat => k `Represents` n)\ng Z n = Evidence (qib n) (Axiom n)\ng (S r) n = g r n\n\nfmt : qib n `Represents` n -> String\nfmt (Axiom n) = \"Axiom \" ++ show n\n\nmain : IO ()\nmain = do\n n <- map (const (the Nat 10000)) (putStrLn \"*oink*\")\n putStrLn . show $ getWitness (f 4 n)\n putStrLn . fmt $ getProof (g 4 n)\n", "meta": {"hexsha": "439355f22537139ed30e53aa815d69537f18857c", "size": 1257, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "test/idris-dev/basic010/Main.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/basic010/Main.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/basic010/Main.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": 28.5681818182, "max_line_length": 75, "alphanum_fraction": 0.6062052506, "num_tokens": 436, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8933094174159129, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.5560487825210275}}
{"text": "module Data.AVL\n\nimport Data.List\n\n-- Boring basic AVL weight balanced BST\n-- ordered on keys to be more versatile\n\nHeight : Type\nHeight = Int\n\nexport\ndata Tree : Type -> Type -> Type where\n Leaf : Tree k a\n Node : (h : Int) -> (key : k) -> (v : a) -> (l : Tree k a) -> (r : Tree k a) -> Tree k a\n\n-- a a a\n-- \\ / -> \\\n-- b -> b b b\n-- \\ / \\ \n-- c a c \nrotateL : Tree k a -> Tree k a\nrotateL (Node hA kA vA lA (Node hB kB vB lB c)) = Node hB kB vB (Node hA kA vA lA lB) c\nrotateL t = t\n\nroLtest1 : rotateL (Node 0 1 'a' Leaf (Node 0 2 'b' Leaf (Node 0 3 'c' Leaf Leaf))) = Node 0 2 'b' (Node 0 1 'a' Leaf Leaf) (Node 0 3 'c' Leaf Leaf)\nroLtest1 = Refl\n\n\nrotateR : Tree k a -> Tree k a\nrotateR (Node hA kA vA (Node hB kB vB c rB) rA) = Node hB kB vB c (Node hA kA vA rB rA)\nrotateR t = t\n\nroRtest1 : rotateR (Node 0 1 'a' (Node 0 2 'b' (Node 0 3 'c' Leaf Leaf) Leaf) Leaf) = Node 0 2 'b' (Node 0 3 'c' Leaf Leaf) (Node 0 1 'a' Leaf Leaf)\nroRtest1 = Refl\n\n\n-- c c\n-- / /\n-- a -> b -> b\n-- \\ / / \\\n-- b a a c\nrotateRL : Tree k a -> Tree k a\nrotateRL Leaf = Leaf\nrotateRL (Node x k v l r) = rotateR (Node x k v (rotateL l) r)\n\nfoobles2 : rotateRL (Node 0 3 'c' (Node 0 1 'a' Leaf (Node 0 2 'b' Leaf Leaf)) Leaf) = Node 0 2 'b' (Node 0 1 'a' Leaf Leaf) (Node 0 3 'c' Leaf Leaf)\nfoobles2 = Refl\n\nrotateLR : Tree k a -> Tree k a\nrotateLR Leaf = Leaf\nrotateLR (Node x k v l r) = rotateL (Node x k v l (rotateR r))\n\nfoobles3 : rotateLR (Node 0 1 'a' Leaf (Node 0 3 'c' (Node 0 2 'b' Leaf Leaf) Leaf)) = Node 0 2 'b' (Node 0 1 'a' Leaf Leaf) (Node 0 3 'c' Leaf Leaf)\nfoobles3 = Refl\n\npublic export\ndata NonEmpty : Tree k a -> Type where\n IsNonEmpty : NonEmpty (Node h k v l r)\n\nexport\nheight : Tree k a -> Int\nheight Leaf = 0\nheight (Node h k v l r) = h\n\ncheckBalance : (t : Tree k a) -> Int\ncheckBalance Leaf = 0\ncheckBalance (Node x k v l r) = height r - height l\n\ndata Balance = LeftHeavy | LeftLean | Neutral | RightLean | RightHeavy\n\ncheckBalance' : Tree k a -> Balance\ncheckBalance' Leaf = Neutral\ncheckBalance' t = let i = checkBalance t\n in if i > 1 then RightHeavy\n else if i == 1 then RightLean\n else if i == -1 then LeftLean\n else if i < -1 then LeftHeavy\n else Neutral\n\nisLeftHeavy : Tree k a -> Bool\nisLeftHeavy t with (checkBalance' t)\n isLeftHeavy t | LeftHeavy = True\n isLeftHeavy t | _ = False\n\nisRightHeavy : Tree k a -> Bool\nisRightHeavy t with (checkBalance' t)\n isRightHeavy t | RightHeavy = True\n isRightHeavy t | _ = False\n\nbalance : Tree k a -> Tree k a\nbalance Leaf = Leaf\nbalance n@(Node h k v l r) = case checkBalance' n of\n LeftHeavy => if isRightHeavy l then rotateRL n else rotateR n\n LeftLean => n\n Neutral => n\n RightLean => n\n RightHeavy => if isLeftHeavy r then rotateLR n else rotateL n\n\nexport\ninsert : Ord k => k -> a -> Tree k a -> Tree k a\ninsert i x Leaf = Node 1 i x Leaf Leaf\ninsert i x n@(Node h k v l r) = case compare i k of\n EQ => n\n LT => balance $ Node h k v (insert i x l) r\n GT => balance $ Node h k v l (insert i x r)\n\nexport\nlookup : Ord k => k -> Tree k a -> Maybe a\nlookup i Leaf = Nothing\nlookup i n@(Node h k v l r) = case compare i k of\n EQ => Just v\n LT => lookup i l\n GT => lookup i r\n\nexport\nfromList : Ord k => List (k,a) -> Tree k a\nfromList = foldr (uncurry insert) Leaf\n\nbt : Tree Int Char\nbt = Node 3 1 '1' Leaf (Node 2 2 '2' (Node 1 3 '3' Leaf Leaf) Leaf)\n\nbt2 : Tree Int Char\nbt2 = Node 3 1 '1' (Node 2 2 '2' (Node 1 3 '3' Leaf Leaf) Leaf) Leaf\n\nbt3 : Tree Int Char\nbt3 = fromList [(1,'1'),(2,'2'),(3,'3')]\n\nfoobles4 : balance (Node 3 1 'a' Leaf (Node 2 3 'c' (Node 1 2 'b' Leaf Leaf) Leaf)) = Node 2 2 'b' (Node 1 1 'a' Leaf Leaf) (Node 1 3 'c' Leaf Leaf)\nfoobles4 = ?dsfdfs\n\n\n\n\n", "meta": {"hexsha": "91d9945435467936863915b99107591a1ca4ab40", "size": 3863, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/AVL.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/AVL.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/AVL.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": 28.828358209, "max_line_length": 149, "alphanum_fraction": 0.5899559928, "num_tokens": 1441, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799929104825007, "lm_q2_score": 0.7122321842389469, "lm_q1q2_score": 0.5555360543238449}}
{"text": "import Data.List1\nimport Data.Nat\nimport Data.String.Parser\n\nimport System.File\n\ndata SnailfishNum = Regular Nat | Pair SnailfishNum SnailfishNum\n\nShow SnailfishNum where\n show (Regular k) = show k\n show (Pair x y) = \"[\" ++ show x ++ \",\" ++ show y ++ \"]\"\n\ndata ReduceResult = None | Done | Add Nat Nat | AddL Nat | AddR Nat\n\nInput : Type\nInput = List1 SnailfishNum\n\npairParser : Parser a -> Parser (a, a)\npairParser p = do fst <- p\n skip $ char ','\n snd <- p\n pure (fst, snd)\n\nnumParser : Parser SnailfishNum\nnumParser = (char '[' *> (uncurry Pair <$> pairParser numParser) <* char ']') <|>\n Regular <$> natural\n\nparser : Parser Input\nparser = do Just l <- fromList <$> some (numParser <* spaces)\n | Nothing => fail \"empty list\"\n pure l\n\n\nreduce : SnailfishNum -> SnailfishNum\nreduce n = case explode 0 n of\n (r, None) => case split r of\n (r, True) => reduce r\n (r, False) => r\n (r, _ ) => reduce r\n where\n split : SnailfishNum -> (SnailfishNum, Bool)\n split (Regular k) =\n if k > 9\n then (Pair (Regular $ divNatNZ k 2 SIsNonZero) (Regular $ divCeilNZ k 2 SIsNonZero), True)\n else (Regular k, False)\n split (Pair x y) = case split x of\n (z, True) => (Pair z y, True)\n (z, False) => let (w, b) = split y in\n (Pair z w, b)\n\n addLeftMost : Nat -> SnailfishNum -> SnailfishNum\n addLeftMost n (Regular k) = Regular $ n + k\n addLeftMost n (Pair x y) = Pair (addLeftMost n x) y\n\n addRightMost : Nat -> SnailfishNum -> SnailfishNum\n addRightMost n (Regular k) = Regular $ n + k\n addRightMost n (Pair x y) = Pair x (addRightMost n y)\n\n explode : Nat -> SnailfishNum -> (SnailfishNum, ReduceResult)\n explode _ (Regular k) = (Regular k, None)\n explode 4 (Pair (Regular k) (Regular j)) = (Regular 0, Add k j)\n explode d (Pair x y) = case explode (min (d + 1) 4) x of\n (z, Done) => (Pair z y, Done)\n (z, (Add k j)) => (Pair z (addLeftMost j y), AddL k)\n (z, (AddL k)) => (Pair z y, AddL k)\n (z, (AddR j)) => (Pair z (addLeftMost j y), Done)\n (z, None) => case explode (min (d + 1) 4) y of\n (w, (Add k j)) => (Pair (addRightMost k z) w, AddR j)\n (w, (AddL k)) => (Pair (addRightMost k z) w, Done)\n (w, r) => (Pair z w, r)\n\nadd : SnailfishNum -> SnailfishNum -> SnailfishNum\nadd n1 n2 = reduce $ Pair n1 n2\n\nmagnitude : SnailfishNum -> Nat\nmagnitude (Regular n) = n\nmagnitude (Pair x y) = 3 * (magnitude x) + 2 * (magnitude y)\n\npart1 : Input -> IO String\npart1 = pure . show . magnitude . foldl1 add\n\npart2 : Input -> IO String\npart2 a = pure $ show $ foldl1 max $ (\\n1 => foldl1 max $ (\\n2 => (magnitude $ add n1 n2)) <$> a) <$> 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": "5218134f57b9e208c722cf17938bf1a855f62dbf", "size": 3416, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "18/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": "18/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": "18/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": 36.7311827957, "max_line_length": 103, "alphanum_fraction": 0.5029274005, "num_tokens": 965, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8615382094310355, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.5550245447127851}}
{"text": "import Control.Monad.State\n\ndata Tree a = Empty | Node (Tree a) a (Tree a)\n\ntestTree : Tree String\ntestTree = Node (Node (Node Empty \"Jim\" Empty) \"Fred\" (Node Empty \"Sheila\" Empty)) \"Alice\" (Node Empty \"Bob\" (Node Empty \"Eve\" Empty))\n\ntestStream : Stream Int\ntestStream = [1..]\n\nflatten : Tree a -> List a\nflatten Empty = []\nflatten (Node left val right) = flatten left ++ (val :: flatten right)\n\nlabelTreeWith : Stream label -> Tree elem -> (Stream label, Tree (label, elem))\nlabelTreeWith lbls Empty = (lbls, Empty)\nlabelTreeWith lbls (Node l e r) = \n let\n (forThis :: forRight, lbldLeft) = labelTreeWith lbls l\n (forNext, lbldRight) = labelTreeWith forRight r\n in\n (forNext, Node lbldLeft (forThis, e) lbldRight)\n\nlabelTreeWith2 : Tree a -> State (Stream label) (Tree (label, a))\nlabelTreeWith2 Empty = pure Empty\nlabelTreeWith2 (Node left elem right) =\n do\n lbldLeft <- labelTreeWith2 left\n (this :: rest) <- get\n put rest\n lbldRight <- labelTreeWith2 right\n pure (Node lbldLeft (this, elem) lbldRight)\n\ndeepFirst : Tree elem -> Tree (Int, elem)\ndeepFirst tree = snd (labelTreeWith testStream tree)\n\ndeepFirst2 : Tree elem -> Tree (Int, elem)\ndeepFirst2 tree = evalState (labelTreeWith2 tree) [1..]\n\ncountEmpty : Tree elem -> State Nat ()\ncountEmpty Empty =\n do\n curr <- get\n put (S curr)\ncountEmpty (Node left _ right) =\n do\n countEmpty left\n countEmpty right\n\ncountEmptyNode : Tree elem -> State (Nat, Nat) ()\ncountEmptyNode Empty =\n do\n (currEmpties, currFull) <- get\n put (S currEmpties, currFull)\ncountEmptyNode (Node left _ right) =\n do\n countEmptyNode left\n countEmptyNode right\n (currEmpties, currFull) <- get\n put (currEmpties, S currFull)\n", "meta": {"hexsha": "844c5ce4be7faaabd016190addc5492851ff96f1", "size": 1738, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "12_1_TreeLabel.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": "12_1_TreeLabel.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": "12_1_TreeLabel.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": 28.4918032787, "max_line_length": 134, "alphanum_fraction": 0.6772151899, "num_tokens": 519, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.7185943925708561, "lm_q1q2_score": 0.5546424094894348}}
{"text": "-- Perl-style pack/unpack\n\nmodule Pack\n\n-- core\n\n-- inp - a parsing-oriented type, i.e. including bits count or similar\n-- information; it's constructors should accept a final argument of\n-- type out\n-- out - a user-friendly type, e.g. Nat or String\nclass Packable inp out where\n total ppack : inp -> Maybe (List Bool)\n total punpack : List Bool -> Maybe (out, List Bool)\n\n-- Verified Packable\ndata T = tt\nclass Packable i o => VerifiedPackable i o (f : o -> i) where\n total v1 : (outv : o) -> maybe T (\\x => x = (outv, List.Nil {a=Bool})) (ppack (f outv) >>= punpack {inp=i} {out=o})\n\n-- collecting all the types, user should only provide functions of\n-- type (out -> inp), e.g. (mkpNat 3)\ndata Pack : Type -> Type -> Type where\n p : Packable i o => (o -> i) -> Pack i o\n (..) : Packable i o => (o -> i) -> Pack a b -> Pack (i, a) (o, b)\n \ninfixr 3 ..\n\n-- actual pack\ntotal mpack : Pack t1 t2 -> t2 -> Maybe (List Bool)\nmpack (p tc) o = ppack (tc o)\nmpack (tc .. pl) (v, vl) = do\n this <- ppack (tc v)\n rest <- mpack pl vl\n return $ this ++ rest\n\n-- and unpack\ntotal munpack : Pack t1 t2 -> List Bool -> Maybe t2\nmunpack (p tc) l = (punpack l) >>= Just . fst\nmunpack (tc .. pl) l = do\n (r, rest) <- punpack l\n next <- munpack pl rest\n return (r, next)\n\n\n\n-- extensions\n\nnatToBits : Nat -> Nat -> List Bool\nnatToBits n Z = []\nnatToBits Z bits = replicate bits False\nnatToBits n (S bits) = natToBits (div n 2) bits ++ [ (mod n 2 /= Z) ]\n\nbitsToNat : List Bool -> Nat -> Nat\nbitsToNat l b = bitsToNat' (reverse l) b\n where bitsToNat' [] b = Z\n bitsToNat' l Z = Z\n bitsToNat' (v :: l) (S b) = (if v then 1 else 0) + 2 * bitsToNat' l b\n\n-- Nat, BE\n\ndata pNat : Nat -> Type where\n mkpNat : (bits : Nat) -> Nat -> pNat bits\n\ninstance Packable (pNat n) Nat where\n ppack mn = case mn of\n (mkpNat n v) => if S (log2 v) <= n\n then Just $ natToBits v n\n else Nothing\n punpack l = if n <= length l\n then Just (bitsToNat (take n l) n, drop n l)\n else Nothing\n\n-- Nat, LE\n\ndata pNatLe : Nat -> Type where\n mkpNatLe : (bits : Nat) -> Nat -> pNatLe bits\n\ninstance Packable (pNatLe n) Nat where\n ppack mn = case mn of\n (mkpNatLe n v) => if S (log2 v) <= n\n then Just $ reverse $ natToBits v n\n else Nothing\n punpack l = if n <= length l\n then Just (bitsToNat (reverse $ take n l) n, drop n l)\n else Nothing\n\n-- Raw bits\n\ndata pBits : Nat -> Type where\n mkpBits : (bits : Nat) -> List Bool -> pBits bits\n\ninstance Packable (pBits n) (List Bool) where\n ppack bl = case bl of\n (mkpBits n l) => if length l == n\n then Just $ l\n else Nothing\n punpack l = if (length l == n) || (length l > n)\n then Just (take n l, drop n l)\n else Nothing\n\n\n\n\n-- Verified pBits\n\ntotal nat_eqb_eq : (x : Nat) -> (y : Nat) -> (x == y = True) -> (x = y)\nnat_eqb_eq Z Z p = refl\nnat_eqb_eq Z (S y) p = FalseElim (trueNotFalse (sym p))\nnat_eqb_eq (S x) Z p = FalseElim (trueNotFalse (sym p))\nnat_eqb_eq (S x) (S y) p = cong {f=S} (nat_eqb_eq x y p)\n\ntotal take_len : (n : Nat) -> (l : List a) -> n = length l -> take n l = l\ntake_len Z [] p = refl\ntake_len Z (x :: xs) p = FalseElim (OnotS p)\ntake_len (S k) [] p = refl\ntake_len (S k) (x :: xs) p = cong {f=(x ::)} $ take_len k xs $ succInjective k (length xs) p\n\ntotal drop_len : (n : Nat) -> (l : List a) -> n = length l -> drop n l = List.Nil {a=a}\ndrop_len Z [] p = refl\ndrop_len Z (x :: xs) p = FalseElim (OnotS p)\ndrop_len (S k) [] p = FalseElim (OnotS (sym p))\ndrop_len (S k) (x :: xs) p = drop_len k xs $ succInjective k (length xs) p\n\ntotal pair : {A : Type} -> {B : Type} -> {a : A} -> {b : B} -> {c : A} -> {d : B} ->\n (a = c) -> (b = d) -> (a, b) = (c, d)\npair ac bd = rewrite ac in cong bd\n\ndata Inspect : a -> Type where\n wi : {A : Type} -> (x : A) -> (y : A) -> (eq: x = y) -> Inspect x\n \ninspect : {A : Type} -> (x : A) -> Inspect x\ninspect x = wi x _ refl\n\nmatch : {A : Type} -> {x : A} -> (y : A) -> {eq : x = y} -> Inspect x\nmatch y {eq} = wi _ y eq\n\n\ninstance VerifiedPackable (pBits n) (List Bool) (mkpBits n) where\n v1 [] = case n of\n Z => refl\n (S m) => tt\n v1 (x :: xs) with (inspect n)\n | match Z {eq} = rewrite eq in tt\n | match (S m) {eq} with (inspect (length xs == m))\n | match True {eq=eq1} = rewrite eq in (rewrite eq1 in cst_lemma)\n where sml : S m = length (x :: xs)\n sml = cong {f=S} $ sym (nat_eqb_eq (length xs) m eq1)\n cst_lemma2 : maybe T (\\x2 => x2 = (x :: xs, List.Nil {a=Bool})) (Just (x :: (take m xs), drop m xs))\n cst_lemma2 = pair (take_len (S m) (x :: xs) sml)\n (drop_len (S m) (x :: xs) sml)\n cst_lemma = rewrite eq1 in cst_lemma2\n | match False {eq=eq1} = rewrite eq in (rewrite eq1 in tt)\n", "meta": {"hexsha": "8525d307cf589fb9d5746b2c2b82238980b95746", "size": 4903, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "playing-around/Pack.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/Pack.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/Pack.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": 32.045751634, "max_line_length": 117, "alphanum_fraction": 0.5531307363, "num_tokens": 1693, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.718594386544335, "lm_q1q2_score": 0.5546424048379037}}
{"text": "module Triple\n\n%default total\n%access public export\n%language LinearTypes\n\ndata Triple : (A : Type) -> (B : Type) -> (C : Type) -> Type where\n MkTriple : {A, B, C : Type} ->\n (1 a : A) -> (1 b : B) -> (1 c : C) ->\n Triple A B C\n\nfst3 : (a,b,c) -> a\nfst3 (x, y, z) = x\n\nsnd3 : (a,b,c) -> b\nsnd3 (x, y, z) = y\n\ntrd3 : (a,b,c) -> c\ntrd3 (x, y, z) = z\n\n||| Dependent Triple 1\n||| Type of A -> (B -> C)\n||| Dual to DTriple 2\ndata DTriple1 : (a : Type) -> (b : a -> Type) ->\n (c : a -> (Type -> Type)) -> Type where\n MkDPair1 : {c : a -> (Type -> Type)} -> {b : a -> Type} ->\n (1 af : a) -> (1 bf : b af) -> (1 cf: (c af) (b af)) ->\n DTriple1 a b c\n\n||| Dependent Triple 2\n||| Type of (A -> B) -> C\n||| Dual to DTriple 1\ndata DTriple2 : (a : Type) -> (b : a -> Type) ->\n (c : (a -> Type) -> Type) -> Type where\n MkDPair2 : {c : (a -> Type) -> Type} -> {b : a -> Type} ->\n (1 af : a) -> (1 bf : b af) -> (1 cf: c b) ->\n DTriple2 a b c\n", "meta": {"hexsha": "d0419b37991659495f3520576883f7c202e10227", "size": 1033, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/Triple.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/Triple.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/Triple.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": 27.1842105263, "max_line_length": 68, "alphanum_fraction": 0.4278799613, "num_tokens": 400, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.6992544335934766, "lm_q1q2_score": 0.5545828526748616}}
{"text": "module Baum\n\n-- ein Baum ist entweder ein leeres Blatt \n-- oder ein Ast mit einem Wert und zwei Unterbäumen\n-- überlege wie der entsprechende Datentyp aussehen könnte\n\n-- data Baum : ... where\n-- Blatt : Baum a\n-- Ast : ... -> Baum a\n \n---------------------------------------------------------------------- \n \n-- ähnlich `Elem` für den Vektor wollen wir eine Datenstruktur\n-- die \"beweist\", dass ein Wert in einem Baum ist, indem der Weg\n-- dorthin aufgezeigt wird\n-- Wie kann das ausehen?\n\n-- data PfadZu : (wert : a) -> (baum : Baum a) -> Type where\n-- ??? lass Dich von Elem / IstDrin inspirieren\n\n----------------------------------------------------------------------\n \n-- jetzt müssen wir noch entscheiden, ob wir einen Weg finden können\n\n-- gibtEsPfad : DecEq a => (zu : a) -> (baum : Baum a) -> Dec (PfadZu zu baum)\n\n----------------------------------------------------------------------\n-- Wenn alles passt sollte `zu0 = Yes (IstLinks (IstRechts Hier))` sein!\n \n-- beispiel : Baum Int\n-- beispiel = Ast 2 (Ast 1 Blatt (Ast 0 Blatt Blatt)) (Ast 3 Blatt Blatt)\n\n-- zu0 : Dec (PfadZu 0 Baum.beispiel)\n-- zu0 = gibtEsPfad _ _\n", "meta": {"hexsha": "01f33681442991e2ce11988cf98eae3c34ddd9c6", "size": 1140, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Projekte/Baum.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": "Projekte/Baum.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": "Projekte/Baum.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": 32.5714285714, "max_line_length": 78, "alphanum_fraction": 0.5377192982, "num_tokens": 303, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8333245870332531, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.5545029846045049}}
{"text": "module Time\n\nimport Coda.Range\n\n%access public export\n%default total\n\n{-\n ISO 8601 Time Package\n\n Time Representation includes:\n\n Hour : Minute : Second (+/-) Offset\n\n Where (+/-) Offset is represented as a TimeZone\n\n And Hour : Minute : Second is represented as an Instant\n\n And the combination of both is represented as a LocalTime\n\n-}\n\n{-\n Type Definitions\n-}\n\ndata Second : Type where\n MkSec : (s : Nat) -> { auto prf : (Dec (0 <= s = s < 60) ) } -> Second\n\n%name Second s,s1,s2,s3\n\ndata Minute : Type where\n MkMin : (m : Nat) -> { auto prf : (Dec (0 <= m = m < 60) ) } -> Minute\n\n%name Minute m,m1,m2,m3\n\ndata Hour : Type where\n MkHour : (h : Nat) -> { auto prf : (Dec (0 <= h = h < 24) ) } -> Hour\n\n%name Hour h,m1,m2,m3\n\ndata Instant : Type where\n MkInstant : (h : Hour) -> (m : Minute) -> (s : Second) -> Instant\n\n%name Instant i,i1,i2,i3\n\ndata Sign : Type where\n (+) : Sign\n (-) : Sign\n\n%name Sign s,s1,s2,s3\n\ndata Offset : Type where\n MkOffset : (sign : Sign) -> (i : Instant) -> Offset\n\n%name Offset off,off1,off2,off3\n\ndata TimeZone : Offset -> Type where\n MkTimeZone : (name : String) -> (offset : Offset) -> TimeZone offset\n\n%name TimeZone tz,tz1,tz2,tz3\n\ndata LocalTime : TimeZone offset -> Type where\n MkLocalTime : (tz : TimeZone offset) -> (i : Instant) -> LocalTime tz\n\n%name LocalTime lt,lt1,lt2,lt3\n\n{-\n Standard Interface Implementations\n-}\n\nEq Second where\n (==) (MkSec s) (MkSec s') = s == s'\n\nOrd Second where\n compare (MkSec s) (MkSec s') = compare s s'\n\nShow Second where\n show (MkSec s) = if s < 10 then \"0\"++show s else show s\n\nEq Minute where\n (==) (MkMin s) (MkMin s') = s == s'\n\nOrd Minute where\n compare (MkMin s) (MkMin s') = compare s s'\n\nShow Minute where\n show (MkMin m) = if m < 10 then \"0\"++show m else show m\n\nEq Hour where\n (==) (MkHour s) (MkHour s') = s == s'\n\nOrd Hour where\n compare (MkHour s) (MkHour s') = compare s s'\n\nShow Hour where\n show (MkHour h) = if h < 10 then \"0\"++show h else show h\n\nEq Instant where\n (==) (MkInstant h m s) (MkInstant h' m' s') = h == h' && m == m' && s == s'\n\nOrd Instant where\n compare (MkInstant h m s) (MkInstant h' m' s') =\n case compare h h' of\n EQ => case compare m m' of\n EQ => compare s s'\n r => r\n r => r\n\nShow Instant where\n show (MkInstant h m s) = \"\" ++ show h ++ \":\" ++ show m ++ \":\" ++ show s\n\nEq Sign where\n (==) (+) (+) = True\n (==) (-) (-) = True\n (==) _ _ = False\n\nOrd Sign where\n compare (+) (-) = GT\n compare (-) (+) = LT\n compare (+) (+) = EQ\n compare (-) (-) = EQ\n\nShow Sign where\n show (+) = \"+\"\n show (-) = \"-\"\n\nEq Offset where\n (==) (MkOffset sign i) (MkOffset sign' i') = sign == sign' && i == i'\n\nOrd Offset where\n compare (MkOffset sign i) (MkOffset sign' i') =\n case compare sign sign' of\n EQ => compare i i'\n r => r\n\nShow Offset where\n show (MkOffset sign i@(MkInstant h m _)) =\n if isZero i\n then \"Z\"\n else show sign ++ show h ++ \":\" ++ show m\n where isZero : Instant -> Bool\n isZero (MkInstant (MkHour Z) (MkMin Z) (MkSec Z)) = True\n isZero _ = False\n\nEq (TimeZone offset) where\n (==) (MkTimeZone name _) (MkTimeZone name' _) = name == name'\n\nOrd (TimeZone offset) where\n compare (MkTimeZone name _) (MkTimeZone name' _) = compare name name'\n\nShow (TimeZone offset) where\n show (MkTimeZone name offset) = show name ++ show offset\n\nEq (LocalTime tz) where\n (==) (MkLocalTime _ i) (MkLocalTime _ i') = i == i'\n\nOrd (LocalTime tz) where\n compare (MkLocalTime _ i) (MkLocalTime _ i') = compare i i'\n\nShow (LocalTime (MkTimeZone name offset)) where\n show (MkLocalTime (MkTimeZone name offset) i) = show i ++ show offset\n\n{-\n Utility Functions\n-}\n\nminuteToSeconds : Minute -> Integer\nminuteToSeconds (MkMin m) = (toIntegerNat m) * 60\n\nhourToSeconds : Hour -> Integer\nhourToSeconds (MkHour h) = (toIntegerNat h) * 60 * 60\n\ninstantToSeconds : Instant -> Integer\ninstantToSeconds (MkInstant h m (MkSec s)) = (hourToSeconds h) +\n (minuteToSeconds m) +\n (toIntegerNat s)\n\nDistance Instant Integer where\n distance (MkRange x y) = (instantToSeconds y) - (instantToSeconds x)\n\ninstantZero : Instant\ninstantZero = (MkInstant (MkHour 0) (MkMin 0) (MkSec 0))\n\nUTC : TimeZone (MkOffset (+) Time.instantZero)\nUTC = MkTimeZone \"UTC\" (MkOffset (+) instantZero)\n", "meta": {"hexsha": "1905a2d937e93795209adfd74bbc39211bfd2c14", "size": 4400, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Coda/Time.idr", "max_stars_repo_name": "ostera/idris-coda", "max_stars_repo_head_hexsha": "0d8b29b7b73aa1ea80bf216e5e6dea5e81156e32", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 4, "max_stars_repo_stars_event_min_datetime": "2017-09-23T00:30:25.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-10T21:24:10.000Z", "max_issues_repo_path": "Coda/Time.idr", "max_issues_repo_name": "ostera/idris-coda", "max_issues_repo_head_hexsha": "0d8b29b7b73aa1ea80bf216e5e6dea5e81156e32", "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": "Coda/Time.idr", "max_forks_repo_name": "ostera/idris-coda", "max_forks_repo_head_hexsha": "0d8b29b7b73aa1ea80bf216e5e6dea5e81156e32", "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": 23.5294117647, "max_line_length": 77, "alphanum_fraction": 0.5988636364, "num_tokens": 1445, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619263765706, "lm_q2_score": 0.6723316991792861, "lm_q1q2_score": 0.5543118878693872}}
{"text": "module Data.HList\r\n\r\nimport Data.Vect\r\n\r\n%access public export\r\n%default total\r\n\r\ndata HList: (n :Nat) -> Vect n Type -> Type where\r\n Nil : HList 0 []\r\n (::) : t -> (HList n tps) -> HList (S n) (t :: tps)\r\n\r\nget : (fin:Fin n1) -> HList n1 tps -> (index fin tps)\r\nget FZ (y :: z) = y\r\nget (FS x) (y :: z) = get x z\r\n\r\nsetWith : (fin:Fin n1) -> HList n1 tps -> ((index fin tps) -> (index fin tps)) -> HList n1 tps\r\nsetWith FZ (x :: z) f = (f x) :: z\r\nsetWith (FS s) (x :: w) y = x :: (setWith s w y)\r\n\r\nset : (fin:Fin n1) -> HList n1 tps -> (index fin tps) -> HList n1 tps\r\nset fin x y = setWith fin x (\\a => y)\r\n\r\nhead : HList (S len) (h :: tps) -> h\r\nhead (x :: y) = x\r\n\r\nLastType : HList (S n) (a :: tps) -> Type\r\nLastType {a} (x :: []) = a\r\nLastType {a} (x :: l1 @ (t :: ts)) = LastType l1\r\n\r\nlast : ( l : HList (S n) (t :: ts) ) -> LastType l\r\nlast (x :: []) = x\r\nlast (x :: l1 @ (y :: z)) = last l1\r\n\r\nZipTypeVect : HList n ts1 -> HList n ts2 -> Vect n Type\r\nZipTypeVect {ts1 = []} {ts2 = []} [] [] = []\r\nZipTypeVect {ts1 = (t :: tps)} {ts2 = (y :: xs)} (x :: z) (w :: s) = (t, y) :: ZipTypeVect z s\r\n\r\nZipType : HList n ts1 -> HList n ts2 -> Type\r\nZipType {n} x y = HList n (ZipTypeVect x y)\r\n\r\nzip : (l1 : HList n ts1) -> ( l2 : HList n ts2) -> ZipType l1 l2\r\nzip [] [] = []\r\nzip (x :: y) (z :: w) = (x, z) :: zip y w\r\n\r\nhlength : HList n ts1 -> Nat\r\nhlength {n} x = n\r\n\r\ntake : (n : Nat) -> ( l : HList (n + m) ts ) -> HList n (take n ts)\r\ntake Z l = []\r\ntake (S k) (x :: y) = x :: take k y\r\n\r\ndrop : (n : Nat) -> ( l : HList (n + m) ts ) -> HList m (drop n ts)\r\ndrop Z l = l\r\ndrop (S k) (x :: y) = drop k y\r\n\r\ninit : HList (S len) (x :: ts) -> HList len (init (x :: ts))\r\ninit (x :: []) = []\r\ninit (x :: l @ (y :: z)) = x :: (init l)\r\n\r\ntail : HList (S len) (x :: ts) -> HList len ts\r\ntail (x :: y) = y\r\n\r\n(++) : ( xs : HList m tms ) -> (ys : HList n tns ) -> HList (m + n) (tms ++ tns)\r\n(++) [] ys = ys\r\n(++) (x :: y) ys = x :: (y ++ ys)\r\n\r\nupdateTypeVect : (fin:Fin n) -> (HList n tps) -> Type -> Vect n Type\r\nupdateTypeVect {n = (S k)} {tps = (t :: xs)} FZ (x :: z) y = y :: xs\r\nupdateTypeVect {n = (S k)} {tps = (t :: xs)} (FS z) (x :: w) y = t :: (updateTypeVect z w y)\r\n\r\nUpdateType : (fin:Fin n) -> (HList n tps) -> Type -> Type\r\nUpdateType fin x y = HList _ $ updateTypeVect fin x y\r\n\r\nupdate : (fin:Fin n) -> (l : HList n tps) -> t -> (UpdateType fin l t)\r\nupdate FZ (y :: z) x = x :: z\r\nupdate (FS y) (z :: w) x = z :: (update y w x)\r\n\r\ninsertAtTypeVect : (fin:Fin (S n)) -> (HList n tps) -> Type -> Vect (S n) Type\r\ninsertAtTypeVect {n = n} {tps = tps} FZ x y = y :: tps\r\ninsertAtTypeVect {n = Z} {tps = []} (FS z) [] y = [y]\r\ninsertAtTypeVect {n = (S k)} {tps = (t :: xs)} (FS z) (x :: w) y = t :: (insertAtTypeVect z w y)\r\n\r\nInsertAtType : (fin:Fin (S n)) -> (HList n tps) -> Type -> Type\r\nInsertAtType fin x y = HList _ $ insertAtTypeVect fin x y\r\n\r\ninsertAt : (fin:Fin (S n)) -> (l : HList n tps) -> t -> InsertAtType fin l t\r\ninsertAt FZ l x = x :: l\r\ninsertAt (FS y) [] x = [x]\r\ninsertAt (FS y) (z :: w) x = z :: insertAt y w x\r\n\r\ndeleteAtTypeVect : (fin:Fin (S n)) -> (HList (S n) tps) -> Vect n Type\r\ndeleteAtTypeVect {tps = (t :: xs)} FZ (x :: y) = xs\r\ndeleteAtTypeVect {tps = (t :: (y :: tps))} (FS FZ) (x :: (z :: w)) = t :: tps\r\ndeleteAtTypeVect {tps = (t :: xs)} (FS (FS y)) (x :: z) = t :: (deleteAtTypeVect (FS y) z)\r\n\r\nDeleteAtType : (fin:Fin (S n)) -> (HList (S n) tps) -> Type\r\nDeleteAtType fin x = HList _ $ deleteAtTypeVect fin x\r\n\r\ndeleteAt : (fin:Fin (S n)) -> (l : HList (S n) tps) -> (DeleteAtType fin l)\r\ndeleteAt FZ (x :: y) = y\r\ndeleteAt (FS FZ) (y :: (x :: z)) = y :: z\r\ndeleteAt (FS (FS x)) (y :: z) = y :: deleteAt (FS x) z\r\n\r\nimplementation Eq (HList 0 []) where\r\n (==) [] [] = True\r\n\r\nimplementation (Eq a, Eq (HList len elems)) => Eq (HList (S len) (a :: elems)) where\r\n (==) (x::xs) (y::ys) = x == y && xs == ys\r\n\r\nimplementation Ord (HList 0 []) where\r\n compare [] [] = EQ\r\n\r\nimplementation (Ord a, Ord (HList len elems)) => Ord (HList (S len) (a :: elems)) where\r\n compare (x::xs) (y::ys) = compare x y `thenCompare` compare xs ys\r\n\r\ninterface Hap (n:Nat) (tps : Vect n Type) (wts : Vect n Type) where\r\n hapTypeVect : HList n tps -> HList n wts -> Vect n Type\r\n hap : (l1:HList n tps) -> (l2:HList n wts) -> HList n $ hapTypeVect l1 l2\r\n\r\nimplementation Hap Z [] [] where\r\n hapTypeVect [] [] = []\r\n hap [] [] = []\r\n\r\nimplementation (hap:Hap n tps wts) => Hap (S n) (a :: tps) ((a -> b) :: wts) where\r\n hapTypeVect {b} (a1 :: tps) (f :: wts) = b :: hapTypeVect tps wts\r\n hap {b} {tps} {wts} (a1 :: tps1) (f :: wts1) = (f a1) :: hap tps1 wts1\r\n", "meta": {"hexsha": "ccb194ada40da1a859316bb4fe70a6bfb2f0c14e", "size": 4629, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Data/HList.idr", "max_stars_repo_name": "gdefacci/idris-hlist", "max_stars_repo_head_hexsha": "9a500aeeacb7be86f6a86d93b4d89fe1db3b5b00", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 2, "max_stars_repo_stars_event_min_datetime": "2017-08-19T17:14:42.000Z", "max_stars_repo_stars_event_max_datetime": "2018-07-09T17:14:04.000Z", "max_issues_repo_path": "Data/HList.idr", "max_issues_repo_name": "gdefacci/idris-hlist", "max_issues_repo_head_hexsha": "9a500aeeacb7be86f6a86d93b4d89fe1db3b5b00", "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": "Data/HList.idr", "max_forks_repo_name": "gdefacci/idris-hlist", "max_forks_repo_head_hexsha": "9a500aeeacb7be86f6a86d93b4d89fe1db3b5b00", "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.4488188976, "max_line_length": 97, "alphanum_fraction": 0.5163102182, "num_tokens": 1848, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7057850402140659, "lm_q2_score": 0.7853085859124002, "lm_q1q2_score": 0.5542590518886346}}
{"text": "> module Nat.open_issues.Main\n\n> %default total\n> %auto_implicits off\n\n> n : Nat\n> -- n = 80\n\n> -- %freeze n\n\n> ns : List Nat\n> ns = [1..n]\n\n> postulate lemma : (m : Nat) -> 2 * (sum [1..m]) = m * (S m)\n\n> q : 2 * (sum ns) = n * (S n)\n> q = lemma n\n\n> {-\n> main : IO ()\n> main = do putStrLn (\"n = \" ++ show n)\n> putStrLn (\"sum ns = \" ++ show (sum ns))\n> -}\n\nFor small |n|, type checking time is roughly constant in |n| and\nexecution time is roughly linear in |n| as one would expect: \n\n n | type check | run\n ======|============|======= \n 10000 | 5.7s | 0.006s\n 20000 | 5.8s | 0.012s\n 40000 | 6.0s | 0.028s\n 80000 | 5.8s | 0.060s\n\nBut uncommenting the computation of |q| yields unacceptable type\nchecking times even for very small |n|:\n\n n | type check | run\n ======|============|======= \n 10 | 6.0s | 0.002s\n 20 | 5.7s | 0.002s\n 40 | 7.6s | 0.002s\n 80 | 29.7s | 0.002s\n 160 | 11m55.0s | 0.002s\n 320 | 243m22.0s | 0.002s\n 640 | killed! | \n\n\n\n", "meta": {"hexsha": "31046d541b17cce3abe57252c6c14adad1e03306", "size": 1063, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "Nat/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": "Nat/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": "Nat/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": 21.26, "max_line_length": 64, "alphanum_fraction": 0.4797742239, "num_tokens": 430, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8459424295406088, "lm_q2_score": 0.6548947425132314, "lm_q1q2_score": 0.5540032495750145}}
{"text": "module Data.Path\n\n%default total\n\n||| Paths in a typed graph as a sequence of edges with source and target nodes matching up domino-style.\n||| AKA reflexive-transitive closure.\npublic export\ndata Path : (t -> t -> Type) -> t -> t -> Type where\n Nil : Path g i i\n (::) : {0 i, j, k : t} ->\n g i j -> Path g j k -> Path g i k\n\nexport\njoinPath : Path g i j -> Path g j k -> Path g i k\njoinPath [] jk = jk\njoinPath (e::ij) jk = e :: joinPath ij jk\n\nexport\nsnocPath : Path g i j -> g j k -> Path g i k\nsnocPath [] f = [f]\nsnocPath (e::ij) f = e :: snocPath ij f\n\nexport\nlengthPath : Path g i j -> Nat\nlengthPath [] = Z\nlengthPath (_::p) = S $ lengthPath p\n\nexport\nmapPath : {0 gt : t -> t -> Type} -> {0 gu : u -> u -> Type} -> {0 f : t -> u}\n -> ({0 i, j : t} -> gt i j -> gu (f i) (f j))\n -> {0 i, j : t} -> Path gt i j -> Path gu (f i) (f j)\nmapPath gf [] = []\nmapPath gf (e::p) = gf e :: mapPath gf p\n\nexport\nfoldPath : {0 gt : t -> t -> Type} -> {0 gu : u -> u -> Type} -> {0 f : t -> u}\n -> ({0 i, j, k : t} -> gt i j -> gu (f j) (f k) -> gu (f i) (f k))\n -> {0 i, j, k : t} -> Path gt i j -> gu (f j) (f k) -> gu (f i) (f k)\nfoldPath gf [] jk = jk\nfoldPath gf (e::ij) jk = gf e (foldPath {gu} gf ij jk)\n\nexport\nfoldlPath : {0 gt : t -> t -> Type} -> {0 gu : u -> u -> Type} -> {0 f : t -> u}\n -> ({0 i, j, k : t} -> gu (f i) (f j) -> gt j k -> gu (f i) (f k))\n -> {0 i, j, k : t} -> gu (f i) (f j) -> Path gt j k -> gu (f i) (f k)\nfoldlPath gf ij [] = ij\nfoldlPath gf ij (e::jk) = foldlPath {gu} gf (gf ij e) jk\n", "meta": {"hexsha": "2036f3d988cadb3ec3b9ff9a3ce2a850146ba0df", "size": 1616, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "libs/contrib/Data/Path.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": "libs/contrib/Data/Path.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": "libs/contrib/Data/Path.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": 33.6666666667, "max_line_length": 104, "alphanum_fraction": 0.4777227723, "num_tokens": 633, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255928, "lm_q2_score": 0.727975443004307, "lm_q1q2_score": 0.5537349879544964}}
{"text": "module Control.Monad.Free\n\n%access public export\n%default total\n\ndata Free : (f : Type -> Type) -> (a : Type) -> Type where\n Pure : a -> Free f a\n Bind : f (Free f a) -> Free f a\n\nFunctor f => Functor (Free f) where\n map f m = assert_total $ case m of\n Pure x => Pure (f x)\n Bind x => Bind (map (map f) x)\n\nFunctor f => Applicative (Free f) where\n pure = Pure\n\n m <*> x = assert_total $ case m of\n Pure f => map f x\n Bind f => Bind (map (<*> x) f)\n\nFunctor f => Monad (Free f) where\n m >>= f = assert_total $ case m of\n Pure x => f x\n Bind x => Bind (map (>>= f) x)\n\nliftFree : Functor f => f a -> Free f a\nliftFree = assert_total $ Bind . map Pure\n\nlowerFree : Monad f => Free f a -> f a\nlowerFree m = assert_total $ case m of\n Pure x => pure x\n Bind f => join (map lowerFree f)\n\niterM : (Monad m, Functor f) => (f (m a) -> m a) -> Free f a -> m a\niterM f m = assert_total $ case m of\n Pure x => pure x\n Bind x => f (map (iterM f) x)\n\nhoistFree : Functor g => ({ a : Type } -> f a -> g a) -> Free f b -> Free g b\nhoistFree f m = assert_total $ case m of\n Pure x => Pure x\n Bind x => Bind (hoistFree f <$> f x)\n\nfoldFree : (Monad m, Functor f) => ({ a : Type } -> f a -> m a) -> Free f b -> m b\nfoldFree f m = assert_total $ case m of\n Pure x => pure x\n Bind x => f x >>= foldFree f\n\ninterface MonadFree (m : Type -> Type) (f : Type -> Type) | m where\n wrap : f (m a) -> m a\n\nMonadFree (Free f) f where\n wrap = assert_total Bind\n", "meta": {"hexsha": "f535ff3aa28316f47c7f035b6fe369a506a38a55", "size": 1463, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Control/Monad/Free.idr", "max_stars_repo_name": "ajhamwood/idris-free", "max_stars_repo_head_hexsha": "919950fb6a9d97c139c2d102402fec094a99c397", "max_stars_repo_licenses": ["BSD-2-Clause"], "max_stars_count": 29, "max_stars_repo_stars_event_min_datetime": "2015-09-12T13:19:32.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-12T01:05:13.000Z", "max_issues_repo_path": "Control/Monad/Free.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": 3, "max_issues_repo_issues_event_min_datetime": "2016-09-28T20:39:30.000Z", "max_issues_repo_issues_event_max_datetime": "2017-12-20T16:08:14.000Z", "max_forks_repo_path": "Control/Monad/Free.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": 9, "max_forks_repo_forks_event_min_datetime": "2017-06-26T15:30:37.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-12T03:00:38.000Z", "avg_line_length": 26.6, "max_line_length": 82, "alphanum_fraction": 0.5755297334, "num_tokens": 496, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8031737775116229, "lm_q2_score": 0.6893056040203135, "lm_q1q2_score": 0.5536321858409261}}
{"text": "module xquant.Spinor.SigKets\n\nimport public xquant.Spinor.Sigmas\nimport public xquant.Core.Types\nimport public xquant.Math.Hilbert\n\nimport Data.Matrix.Algebraic\nimport Data.Complex\nimport Data.ZZ\n\ninfixl 3 <\\>\ninfixl 3 <|>\ninfixr 4 >\ninfixr 7 <&>\n\n%default total\n\n\n---- State Data ----\n\n\n||| Spin orientation datatype - no identity option, unlike Pauli data type,\n||| though it could possibly be added to represent a neutral density matrix\ndata Orient = X | Y | Z\n\ndata Spin = Up | Down\n\ninstance Eq Spin where\n Up == Up = True\n Down == Down = True\n Up == Down = False\n Down == Up = False\n\n||| basic spin orientation datatype\ndata EigenSpin = Eigenspin Orient Spin\n\n||| collumn 'ket' vector for multiple spins\ndata KetSpins : Nat -> Type where\n kPhase : Phase -> KetSpins Z\n kS : EigenSpin -> KetSpins k -> KetSpins (S k)\n\n||| row 'bra' vector for multiple spins\ndata BraSpins : Nat -> Type where\n bPhase : Phase -> BraSpins Z\n bS : EigenSpin -> BraSpins k -> BraSpins (S k)\n\n||| convert a bra to a ket\nbk : BraSpins n -> KetSpins n\nbk (bPhase p) = kPhase $ star p\nbk (bS e bs) = kS e (bk bs)\n\n||| convert a ket to a bra\nkb : KetSpins n -> BraSpins n\nkb (kPhase p) = bPhase $ star p\nkb (kS e ks) = bS e (kb ks)\n\n||| easy initialize bra\nbra : EigenSpin -> BraSpins 1\nbra e = bS e $ bPhase P1\n\n||| easy initialize ket\nket : EigenSpin -> KetSpins 1\nket e = kS e $ kPhase P1\n\ninstance Show Orient where\n show X = \"X\"\n show Y = \"Y\"\n show Z = \"Z\"\n\ninstance Show Spin where\n show Up = \"Up\"\n show Down = \"Dn\"\n\ninstance Show EigenSpin where\n show (Eigenspin o s) = (show o) ++ \"-\" ++ (show s)\n\n||| EigenSpin shorthands\nupX : EigenSpin\nupX = Eigenspin X Up\ndownX : EigenSpin\ndownX = Eigenspin X Down\n\nupY : EigenSpin\nupY = Eigenspin Y Up\ndownY : EigenSpin\ndownY = Eigenspin Y Down\n\nupZ : EigenSpin\nupZ = Eigenspin Z Up\ndownZ : EigenSpin\ndownZ = Eigenspin Z Down\n\nuX : EigenSpin\nuX = upX\ndX : EigenSpin\ndX = downX\n\nuY : EigenSpin\nuY = upY\ndY : EigenSpin\ndY = downY\n\nuZ : EigenSpin\nuZ = upZ\ndZ : EigenSpin\ndZ = downZ\n\n||| Single abstract sigma acting on ket\nObsKet1 : Sigma 1 -> KetSpins 1 -> KetSpins 1\nObsKet1 (Sig SI $ sPhase p1) (kS (Eigenspin o ud) (kPhase p2)) = kS (Eigenspin o ud) (kPhase $ p1 <+> p2)\nObsKet1 (Sig SX $ sPhase p1) (kS (Eigenspin X Up) (kPhase p2)) = kS (Eigenspin X Up) (kPhase $ p1 <+> p2)\nObsKet1 (Sig SX $ sPhase p1) (kS (Eigenspin X Down) (kPhase p2)) = kS (Eigenspin X Down) (kPhase $ p1 <+> p2 <+> M1)\nObsKet1 (Sig SX $ sPhase p1) (kS (Eigenspin Y Up) (kPhase p2)) = kS (Eigenspin Y Down) (kPhase $ p1 <+> p2 <+> Pi)\nObsKet1 (Sig SX $ sPhase p1) (kS (Eigenspin Y Down) (kPhase p2)) = kS (Eigenspin Y Up) (kPhase $ p1 <+> p2 <+> P1)\nObsKet1 (Sig SX $ sPhase p1) (kS (Eigenspin Z Up) (kPhase p2)) = kS (Eigenspin Z Down) (kPhase $ p1 <+> p2)\nObsKet1 (Sig SX $ sPhase p1) (kS (Eigenspin Z Down) (kPhase p2)) = kS (Eigenspin Z Up) (kPhase $ p1 <+> p2)\nObsKet1 (Sig SY $ sPhase p1) (kS (Eigenspin X Up) (kPhase p2)) = kS (Eigenspin Y Up) (kPhase $ p1 <+> p2)\nObsKet1 (Sig SY $ sPhase p1) (kS (Eigenspin X Down) (kPhase p2)) = kS (Eigenspin Y Down) (kPhase $ p1 <+> p2 <+> M1)\nObsKet1 (Sig SY $ sPhase p1) (kS (Eigenspin Y Up) (kPhase p2)) = kS (Eigenspin Z Down) (kPhase $ p1 <+> p2 <+> Pi)\nObsKet1 (Sig SY $ sPhase p1) (kS (Eigenspin Y Down) (kPhase p2)) = kS (Eigenspin X Up) (kPhase $ p1 <+> p2 <+> Mi)\nObsKet1 (Sig SY $ sPhase p1) (kS (Eigenspin Z Up) (kPhase p2)) = kS (Eigenspin Z Down) (kPhase $ p1 <+> p2 <+> Pi)\nObsKet1 (Sig SY $ sPhase p1) (kS (Eigenspin Z Down) (kPhase p2)) = kS (Eigenspin Z Up) (kPhase $ p1 <+> p2 <+> M1)\nObsKet1 (Sig SZ $ sPhase p1) (kS (Eigenspin X Up) (kPhase p2)) = kS (Eigenspin X Down) (kPhase $ p1 <+> p2 <+> M1)\nObsKet1 (Sig SZ $ sPhase p1) (kS (Eigenspin X Down) (kPhase p2)) = kS (Eigenspin X Up) (kPhase $ p1 <+> p2 <+> M1)\nObsKet1 (Sig SZ $ sPhase p1) (kS (Eigenspin Y Up) (kPhase p2)) = kS (Eigenspin Y Down) (kPhase $ p1 <+> p2 <+> M1)\nObsKet1 (Sig SZ $ sPhase p1) (kS (Eigenspin Y Down) (kPhase p2)) = kS (Eigenspin Y Up) (kPhase $ p1 <+> p2 <+> M1)\nObsKet1 (Sig SZ $ sPhase p1) (kS (Eigenspin Z Up) (kPhase p2)) = kS (Eigenspin Z Up) (kPhase $ p1 <+> p2)\nObsKet1 (Sig SZ $ sPhase p1) (kS (Eigenspin Z Down) (kPhase p2)) = kS (Eigenspin Z Down) (kPhase $ p1 <+> p2 <+> M1)\n\ntimesPhase : Phase -> KetSpins n -> KetSpins n\ntimesPhase p1 (kPhase p2) = kPhase (p1 <+> p2)\ntimesPhase p1 (kS e es) = kS e (timesPhase p1 es)\n\ntopOrientation : KetSpins (S n) -> Orient\ntopOrientation (kS (Eigenspin o s) more) = o\n\ntopKetSpin : KetSpins (S n) -> EigenSpin\ntopKetSpin (kS e es) = e\n\nlastSpin : KetSpins (S k) -> EigenSpin\nlastSpin (kS e (kPhase ph)) = e\nlastSpin (kS e (kS e2 es)) = lastSpin (kS e2 es)\n\nkPack : EigenSpin -> KetSpins 1\nkPack e = kS e (kPhase P1)\n\nkGetPhase : KetSpins n -> Phase\nkGetPhase (kPhase p) = p\nkGetPhase (kS (Eigenspin o s) x) = kGetPhase x\n\n||| Apply Sigma operator to abstract multi-qubit states\nObsKet : Sigma n -> KetSpins n -> KetSpins n\nObsKet (sPhase p1) (kPhase p2) = kPhase $ p1 <+> p2\nObsKet (Sig pl s) (kS k ks) with (ObsKet1 (pack pl) (kPack k))\n | r = kS (topKetSpin r) (timesPhase (kGetPhase r) (ObsKet s ks))\n\n||| Infix op for Sigma-Ket multiply\n(>) : Sigma n -> KetSpins n -> KetSpins n\n(>) = ObsKet\n\n||| Infix op for Bra-Sigma multiply\n(<\\>) : BraSpins n -> Sigma n -> BraSpins n\n(<\\>) b s = kb $ ObsKet s (bk b)\n\n||| Another alias for Bra-Sigma multiply, for maximal harmony with written convention\n(<|>) : BraSpins n -> Sigma n -> BraSpins n\n(<|>) = (<\\>)\n\ninstance Show (KetSpins n) where\n show (kPhase phase) = show phase\n show s = (Prefix s) ++ \"[\" ++ (suffix s) ++ \"]\" where\n suffix : KetSpins n -> String\n suffix (kPhase ph) = \"\"\n suffix (kS p (kPhase ph)) = (show p)\n suffix (kS p s) = (show p) ++ (suffix s)\n Prefix : KetSpins n -> String\n Prefix (kPhase (Sign a b)) = (if a then \"-\" else \"\") ++ (if b then \"i \" else \"\")\n Prefix (kS p s) = Prefix s\n\n||| Tensor product for abstract multi-qubit kets\nox : KetSpins n -> KetSpins m -> KetSpins (n + m)\nox e (kPhase ph) ?= {Ket_OTimes_Lemma_1} timesPhase ph e\nox (kPhase ph) e = timesPhase ph e\nox (kS e1 es1) (kS e2 es2) ?= {Ket_OTimes_Lemma_2} ox (dropLast $ kS e1 es1)\n (kS (lastSpin $ kS e1 es1) (kS e2 es2)) where\n dropLast : KetSpins (S k) -> KetSpins k\n dropLast (kS e (kPhase ph)) = kPhase ph\n dropLast (kS e (kS e2 es)) = kS e (dropLast $ kS e2 es)\n\n||| Infix tensor multiply kets\nKet.(<&>) : KetSpins n -> KetSpins m -> KetSpins (n + m)\nKet.(<&>) = ox\n\n||| Infix tensor multiply bras\nBra.(<&>) : BraSpins n -> BraSpins m -> BraSpins (n + m)\nBra.(<&>) b1 b2 = kb $ ox (bk b1) (bk b2)\n\n\n---- Numeric State & Operator Data ----\n\n\n||| Phase to complex number\nPhase.comZ : Phase -> Complex ZZ\nPhase.comZ (Sign False False) = c1\nPhase.comZ (Sign False True) = ci\nPhase.comZ (Sign True False) = m1\nPhase.comZ (Sign True True) = mi\n\n||| Phase to complex float\nPhase.comF : Phase -> Complex Float\nPhase.comF (Sign False False) = c1\nPhase.comF (Sign False True) = ci\nPhase.comF (Sign True False) = m1\nPhase.comF (Sign True True) = mi\n\n||| Integral Sigma 1's\nsx : QubitOp 1 ZZ\nsx = [[c0, c1], [c1, c0]]\n\nsy : QubitOp 1 ZZ\nsy = [[c0, mi], [ci, c0]]\n\nsz : QubitOp 1 ZZ\nsz = [[c1, c0], [c0, m1]]\n\nsi : QubitOp 1 ZZ\nsi = [[c1, c0], [c0, c1]]\n\nPauli.comZ : Pauli -> QubitOp 1 ZZ\nPauli.comZ SX = sx\nPauli.comZ SY = sy\nPauli.comZ SZ = sz\nPauli.comZ SI = si\n\n||| Floating Sigma 1's\nPauli.comF : Pauli -> QubitOp 1 Float\nPauli.comF SX = (0.5 :+ 0) <#> [[c0, c1], [c1, c0]]\nPauli.comF SY = (0.5 :+ 0) <#> [[c0, mi], [ci, c0]]\nPauli.comF SZ = (0.5 :+ 0) <#> [[c1, c0], [c0, m1]]\nPauli.comF SI = (0.5 :+ 0) <#> [[c1, c0], [c0, c1]]\n\n||| Sigma n to matrix\nSigma.comF : Sigma n -> QubitOp n Float\nSigma.comF (sPhase ph) = [[comF ph]]\nSigma.comF (Sig p s) = (comF p) <&> (comF s)\n\n||| Sigma n to matrix\nSigma.comZ : Sigma n -> QubitOp n ZZ\nSigma.comZ (sPhase ph) = [[comZ ph]]\nSigma.comZ (Sig p s) = (comZ p) <&> (comZ s)\n\n\n||| Numeric KetSpin vectors\nxUp : Qubit 1 Float\nxUp = normalize [c1, c1]\n\nxDown : Qubit 1 Float\nxDown = normalize [m1, c1]\n\nyUp : Qubit 1 Float\nyUp = normalize [mi, c1]\n\nyDown : Qubit 1 Float\nyDown = normalize [ci, c1]\n\nzUp : Qubit 1 Float\nzUp = [c1, c0]\n\nzDown : Qubit 1 Float\nzDown = [c0, c1]\n\n||| [single] KetSpin to numeric vector\nSpin.matF : EigenSpin -> QubitKet 1 Float\nSpin.matF (Eigenspin X Up) = col xUp\nSpin.matF (Eigenspin X Down) = col xDown\nSpin.matF (Eigenspin Y Up) = col yUp\nSpin.matF (Eigenspin Y Down) = col yDown\nSpin.matF (Eigenspin Z Up) = col zUp\nSpin.matF (Eigenspin Z Down) = col zDown\n\n||| [single] KetSpin to numeric vector\nKetSpins.matF : KetSpins n -> QubitKet n Float\nKetSpins.matF (kPhase ph) = [[comF ph]]\nKetSpins.matF (kS e k) = (Spin.matF e) <&> (KetSpins.matF k)\n\n||| Bra to row-vector matrix\nBraSpins.matF : BraSpins n -> QubitBra n Float\nBraSpins.matF (bPhase ph) = [[comF (star ph)]]\nBraSpins.matF (bS e b) = (transpose $ Spin.matF e) <&> (BraSpins.matF b)\n\n||| Bra times Ket to complex number\nBra.(<\\>) : Ring a => BraSpins n -> KetSpins n -> Complex Float\nBra.(<\\>) b k = index 0 $ index 0 $ (matF b) <> (matF k)\n\n\n||| Sigma operators commute\ndata Commutes : Sigma n -> Sigma n -> Type where\n CommZero : (x : Sigma Z) -> (y : Sigma Z) -> Commutes x y\n CommSucc : (a : Sigma 1) -> (b : Sigma 1) -> Commutes x y -> Commutes (a <&> x) (b <&> y)\n\n||| Test for Sigma commutation\ncommute : Sigma n -> Sigma n -> Bool\ncommute (sPhase x) (sPhase y) = True\ncommute (Sig p1 s1) (Sig p2 s2) = xor (p1 /= p2) $ commute s1 s2\n\n||| Whether each non-identity Pauli operator occurs an even number of times\nqubitParity : List Pauli -> Vect 3 Bool\nqubitParity [] = [False, False, False]\nqubitParity (SI :: ss) = qubitParity ss\nqubitParity (SX :: ss) = updateAt 0 not $ qubitParity ss\nqubitParity (SY :: ss) = updateAt 1 not $ qubitParity ss\nqubitParity (SZ :: ss) = updateAt 2 not $ qubitParity ss\n\n||| All Sigmas of a given order\nallSigmas : (n : Nat) -> List $ Sigma n\nallSigmas Z = [sPhase P1]\nallSigmas (S n) = allSigmas n >>= (\\s => [Sig SI s, Sig SX s, Sig SY s, Sig SZ s])\n\n||| All pairs of Sigmas at the given order\nsigPair : (n : Nat) -> List $ Vect 2 (Sigma n)\nsigPair n = [ [s1,s2] | s1 <- (allSigmas n), s2 <- (allSigmas n) ]\n\n\n--------------- Proofs ---------------\n\nKet_OTimes_Lemma_1 = proof\n intro\n rewrite (plusZeroRightNeutral n)\n intros\n trivial\n\nKet_OTimes_Lemma_2 = proof\n intros\n rewrite sym $ plusSuccRightSucc k (S k1)\n trivial\n", "meta": {"hexsha": "e504d37ecb5bcf73ab6dbfb995e601b550052f0f", "size": 10607, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/xquant/Spinor/SigKets.idr", "max_stars_repo_name": "fieldstrength/xquant", "max_stars_repo_head_hexsha": "b94d87609aa63af2d88b6cca50f85b58a00fc92f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 3, "max_stars_repo_stars_event_min_datetime": "2018-06-16T23:34:08.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-26T04:22:56.000Z", "max_issues_repo_path": "src/xquant/Spinor/SigKets.idr", "max_issues_repo_name": "fieldstrength/xquant", "max_issues_repo_head_hexsha": "b94d87609aa63af2d88b6cca50f85b58a00fc92f", "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/xquant/Spinor/SigKets.idr", "max_forks_repo_name": "fieldstrength/xquant", "max_forks_repo_head_hexsha": "b94d87609aa63af2d88b6cca50f85b58a00fc92f", "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.568452381, "max_line_length": 116, "alphanum_fraction": 0.6236447629, "num_tokens": 4206, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428946, "lm_q2_score": 0.7025300698514777, "lm_q1q2_score": 0.5535453579131611}}
{"text": "record Four a b c d where\n constructor MkFour\n x : a\n y : b\n z : c\n w : d\n\nfirstTwo : Four a b c d -> (a, b)\nfirstTwo $ MkFour {x, y, _} = (x, y)\n\nrecord X where\n constructor MkX\n x : Int\n y : Nat\n z : Integer\n\nSomeX : Monad m => m X\nSomeX = pure $ MkX {x=5} {y=3} {z=10}\n\nanalyzeX : Monad m => m Integer\nanalyzeX = do\n MkX {y, z, _} <- SomeX\n pure $ z + natToInteger y\n", "meta": {"hexsha": "e96d2d2ff4e0c8217590c64be3d9675a93e7affe", "size": 381, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "RecordNamedMatch.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": "RecordNamedMatch.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": "RecordNamedMatch.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.875, "max_line_length": 37, "alphanum_fraction": 0.5669291339, "num_tokens": 158, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.7025300573952052, "lm_q1q2_score": 0.5535453480984756}}
{"text": "module Sub13LTE108t111\n\nimport ProofColDivSeqBase\nimport ProofColDivSeqPostulate\n\n%default total\n\n\n-- 6(18t+18)+3 --FB[5,-1,-2]--> 6(8t+7)+3\nexport\nlte108t111 : (l : Nat) -> LTE (S (S (S (S (S (S (S (S (l+l+l+l)+(l+l+l+l)))))))))\n (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)))))))))\nlte108t111 Z = (lteSuccRight . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc) LTEZero\nlte108t111 (S l) =\n let lemma = lte108t111 l in\n rewrite (sym (plusSuccRightSucc l l)) in\n rewrite (sym (plusSuccRightSucc (plus l l) l)) in\n rewrite (sym (plusSuccRightSucc (plus (plus l l) l) l)) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus (plus l l) l) l) (S (S (S (plus (plus (plus l l) l) l)))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus l l) l) l) (S (S (plus (plus (plus l l) l) l))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus l l) l) l) (S (plus (plus (plus l l) l) l)))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus l l) l) l) (plus (plus (plus l l) l) l))) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus l l) l) (S (S (S (S (plus (plus l l) l))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus l l) l) (S (S (S (plus (plus l l) l)))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus l l) l) (S (S (plus (plus l l) l))))) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))\n (S (S (S (S (S (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l)))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))\n (S (S (S (S (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))\n (S (S (S (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l)))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))\n (S (S (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))\n (S (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l)))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))\n (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))) in\n\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus l l) l) (S (S (plus (plus l l) l)))) (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))\n (S (S (S (S (S (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l)))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus l l) l) (S (S (plus (plus l l) l)))) (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))\n (S (S (S (S (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus l l) l) (S (S (plus (plus l l) l)))) (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))\n (S (S (S (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l)))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus l l) l) (S (S (plus (plus l l) l)))) (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))\n (S (S (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus l l) l) (S (S (plus (plus l l) l)))) (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))\n (S (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l)))))))))) in\n rewrite (sym (plusSuccRightSucc (plus (plus (plus (plus l l) l) (S (S (plus (plus l l) l)))) (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))\n (S (S (S (plus (plus (plus l l) l) (S (S (plus (plus l l) l))))))))) in\n (lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . lteSuccRight . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc . LTESucc) lemma\n\n\n\n", "meta": {"hexsha": "d372d0a319d82a1f1ab8d859e5ac048cb65cec92", "size": 4548, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "program3/Sub14LTE108t111.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/Sub14LTE108t111.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/Sub14LTE108t111.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": 78.4137931034, "max_line_length": 239, "alphanum_fraction": 0.5043975374, "num_tokens": 1785, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8840392817460332, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.5535183679207353}}
{"text": "> module SequentialDecisionProblems.NonDeterministicDefaults\n\n> import Data.List\n> import Data.List.Quantifiers\n\n> import SequentialDecisionProblems.CoreTheory\n> import SequentialDecisionProblems.Utils\n\n> import List.Operations\n> import List.Properties\n\n> %default total\n> %auto_implicits off\n\n\nIn non-deterministic SDPs, |M = List|:\n\n> SequentialDecisionProblems.CoreTheory.M = \n> List\n\nThus, |M| is a functor:\n\n> SequentialDecisionProblems.CoreTheory.fmap = \n> List.Operations.fmap\n\n, |M| is a monad:\n\n> SequentialDecisionProblems.Utils.ret =\n> List.Operations.ret\n\n> SequentialDecisionProblems.Utils.bind =\n> List.Operations.bind\n\nMoreover, |M| is a container monad\n\n> SequentialDecisionProblems.CoreTheory.Elem =\n> Data.List.Elem\n\n> SequentialDecisionProblems.CoreTheory.NotEmpty =\n> List.Operations.NonEmpty\n\n> SequentialDecisionProblems.CoreTheory.All =\n> Data.List.Quantifiers.All\n\n> SequentialDecisionProblems.CoreTheory.elemNotEmptySpec0 =\n> List.Properties.elemNonEmptySpec0\n\n> SequentialDecisionProblems.CoreTheory.elemNotEmptySpec1 =\n> List.Properties.elemNonEmptySpec1\n\n> SequentialDecisionProblems.CoreTheory.tagElem = \n> List.Operations.tagElem\n\n> SequentialDecisionProblems.CoreTheory.allElemSpec0 =\n> List.Properties.containerMonadSpec3\n\nand |All| and |NotEmpty| are finite and decidable:\n\n> SequentialDecisionProblems.Utils.finiteAll = \n> List.Properties.finiteAll\n\n> SequentialDecisionProblems.Utils.finiteNotEmpty =\n> List.Properties.finiteNonEmpty\n\n> SequentialDecisionProblems.Utils.decidableAll = \n> List.Properties.decidableAll\n\n> SequentialDecisionProblems.Utils.decidableNotEmpty =\n> List.Properties.decidableNonEmpty\n\n\n> {-\n\n> ---}\n\n", "meta": {"hexsha": "da1103f93e4ff058354b5162d00c149f6544f5f5", "size": 1692, "ext": "lidr", "lang": "Idris", "max_stars_repo_path": "SequentialDecisionProblems/NonDeterministicDefaults.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/NonDeterministicDefaults.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/NonDeterministicDefaults.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": 22.2631578947, "max_line_length": 60, "alphanum_fraction": 0.7901891253, "num_tokens": 408, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8633916170039421, "lm_q2_score": 0.6406358548398982, "lm_q1q2_score": 0.5531196266209224}}
{"text": "\nmodule Part2.Sez10_3_hiding\n\n-- export type, not constructors (symilar to typical approach in Haskell)\nexport\ndata Shape = Triangle Double Double\n | Rectangle Double Double\n | Circle Double\n\n-- export these instead of constructors (symilar to typical approach in Haskell)\n-- only in Idris we can pattern match on these!\nexport\ntriangle : Double -> Double -> Shape\ntriangle = Triangle\n\nexport\nrectangle : Double -> Double -> Shape\nrectangle = Rectangle\n\nexport\ncircle : Double -> Shape\ncircle = Circle\n\n-- exports view (with contructors for client to pattern match on) instead of \n-- Shape constructors\n-- note exported functions used on the RHS of constructors\npublic export\ndata ShapeView : Shape -> Type where\n STriangle : ShapeView (triangle base height)\n SRectangle : ShapeView (rectangle width height)\n SCircle : ShapeView (circle radius)\n\nexport\nshapeView : (s : Shape) -> ShapeView s\nshapeView (Triangle x y) = STriangle\nshapeView (Rectangle x y) = SRectangle\nshapeView (Circle x) = SCircle\n\n-- example client code \n-- can use elaborate pattern match that reflects on the RHS of ShapeView \n-- using exported functions\narea : Shape -> Double\narea s with (shapeView s)\n area (triangle base height) | STriangle = 0.5 * base * height\n area (rectangle width height) | SRectangle = width * height\n area (circle radius) | SCircle = pi * radius * radius\n\n{-\n*Part2/Sez10_3_hiding> area (circle 1)\n3.141592653589793 : Double\n-}\n", "meta": {"hexsha": "3cb4638fad6c888310ceaa908f75f2df4541711a", "size": 1462, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Part2/Sez10_3_hiding.idr", "max_stars_repo_name": "rpeszek/IdrisTddNotes", "max_stars_repo_head_hexsha": "37bca29819315be6f4001d0fe42ae101116fc06d", "max_stars_repo_licenses": ["BSD-3-Clause"], "max_stars_count": 40, "max_stars_repo_stars_event_min_datetime": "2018-06-07T06:18:02.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-24T06:08:35.000Z", "max_issues_repo_path": "src/Part2/Sez10_3_hiding.idr", "max_issues_repo_name": "rpeszek/IdrisTddNotes", "max_issues_repo_head_hexsha": "37bca29819315be6f4001d0fe42ae101116fc06d", "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/Part2/Sez10_3_hiding.idr", "max_forks_repo_name": "rpeszek/IdrisTddNotes", "max_forks_repo_head_hexsha": "37bca29819315be6f4001d0fe42ae101116fc06d", "max_forks_repo_licenses": ["BSD-3-Clause"], "max_forks_count": 4, "max_forks_repo_forks_event_min_datetime": "2018-07-08T18:55:19.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-22T09:25:43.000Z", "avg_line_length": 28.1153846154, "max_line_length": 80, "alphanum_fraction": 0.7311901505, "num_tokens": 361, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.7662936430859597, "lm_q1q2_score": 0.5530672309263277}}
{"text": "module Algebra.Solver.Ring.Sum\n\nimport Algebra.Solver.Ring.Expr\nimport Algebra.Solver.Ring.Prod\nimport Algebra.Solver.Ring.SolvableRing\nimport Algebra.Solver.Ring.Util\n\n%default total\n\n||| A single term in a normalized arithmetic expressions.\n|||\n||| This is a product of all variables each raised to\n||| a given power, multiplied with a factors (which is supposed\n||| to reduce during elaboration).\npublic export\nrecord Term (a : Type) (as : List a) where\n constructor T\n factor : a\n prod : Prod a as\n\n||| Evaluate a term.\npublic export\neterm : Ring a => {as : List a} -> Term a as -> a\neterm (T f p) = f * eprod p\n\n||| Negate a term.\npublic export\nnegTerm : Ring a => Term a as -> Term a as\nnegTerm (T f p) = T (negate f) p\n\n||| Normalized arithmetic expression in a commutative\n||| ring (represented as an (ordered) sum of terms).\npublic export\ndata Sum : (a : Type) -> (as : List a) -> Type where\n Nil : {0 as : List a} -> Sum a as\n (::) : {0 as : List a} -> Term a as -> Sum a as -> Sum a as\n\n||| Evaluate a sum of terms.\npublic export\nesum : Ring a => {as : List a} -> Sum a as -> a\nesum [] = 0\nesum (x :: xs) = eterm x + esum xs\n\n||| Negate a sum of terms.\npublic export\nnegate : Ring a => Sum a as -> Sum a as\nnegate [] = []\nnegate (x :: y) = negTerm x :: negate y\n\n\n--------------------------------------------------------------------------------\n-- Normalizer\n--------------------------------------------------------------------------------\n\n||| Add two sums of terms.\n|||\n||| The order of terms will be kept. If two terms have identical\n||| products of variables, they will be unified by adding their\n||| factors.\npublic export\nadd : SolvableRing a => Sum a as -> Sum a as -> Sum a as\nadd [] ys = ys\nadd xs [] = xs\nadd (T m x :: xs) (T n y :: ys) = case compProd x y of\n LT => T m x :: add xs (T n y :: ys)\n GT => T n y :: add (T m x :: xs) ys\n EQ => T (m + n) y :: add xs ys\n\n||| Normalize a sum of terms by removing all terms with a\n||| `zero` factor.\npublic export\nnormSum : SolvableRing a => Sum a as -> Sum a as\nnormSum [] = []\nnormSum (T f p :: y) = case isZero f of\n Just refl => normSum y\n Nothing => T f p :: normSum y\n\n||| Multiplies a single term with a sum of terms.\npublic export\nmult1 : SolvableRing a => Term a as -> Sum a as -> Sum a as\nmult1 (T f p) (T g q :: xs) = T (f * g) (mult p q) :: mult1 (T f p) xs\nmult1 _ [] = []\n\n||| Multiplies two sums of terms.\npublic export\nmult : SolvableRing a => Sum a as -> Sum a as -> Sum a as\nmult [] ys = []\nmult (x :: xs) ys = add (mult1 x ys) (mult xs ys)\n\n||| Normalizes an arithmetic expression to a sum of products.\npublic export\nnorm : SolvableRing a => {as : List a} -> Expr a as -> Sum a as\nnorm (Lit n) = [T n one]\nnorm (Var x y) = [T 1 $ fromVar y]\nnorm (Neg x) = negate $ norm x\nnorm (Plus x y) = add (norm x) (norm y)\nnorm (Mult x y) = mult (norm x) (norm y)\nnorm (Minus x y) = add (norm x) (negate $ norm y)\n\n||| Like `norm` but removes all `zero` terms.\npublic export\nnormalize : SolvableRing a => {as : List a} -> Expr a as -> Sum a as\nnormalize e = normSum (norm e)\n\n--------------------------------------------------------------------------------\n-- Proofs\n--------------------------------------------------------------------------------\n\n-- Adding two sums via `add` preserves the evaluation result.\n0 padd : SolvableRing a\n => (x,y : Sum a as)\n -> esum x + esum y === esum (add x y)\npadd [] xs = plusZeroLeftNeutral\npadd (x :: xs) [] = plusZeroRightNeutral\npadd (T m x :: xs) (T n y :: ys) with (compProd x y) proof eq\n _ | LT = Calc $\n |~ (m * eprod x + esum xs) + (n * eprod y + esum ys)\n ~~ m * eprod x + (esum xs + (n * eprod y + esum ys))\n ..< plusAssociative\n ~~ m * eprod x + esum (add xs (T n y :: ys))\n ... cong (m * eprod x +) (padd xs (T n y :: ys))\n\n _ | GT = Calc $\n |~ (m * eprod x + esum xs) + (n * eprod y + esum ys)\n ~~ n * eprod y + ((m * eprod x + esum xs) + esum ys)\n ..< p213\n ~~ n * eprod y + esum (add (T m x :: xs) ys)\n ... cong (n * eprod y +) (padd (T m x :: xs) ys)\n\n _ | EQ = case pcompProd x y eq of\n Refl => Calc $\n |~ (m * eprod x + esum xs) + (n * eprod x + esum ys)\n ~~ (m * eprod x + n * eprod x) + (esum xs + esum ys)\n ... p1324\n ~~ (m + n) * eprod x + (esum xs + esum ys)\n ..< cong (+ (esum xs + esum ys)) rightDistributive\n ~~ (m + n) * eprod x + esum (add xs ys)\n ... cong ((m + n) * eprod x +) (padd xs ys)\n\n-- Small utility lemma\n0 psum0 : SolvableRing a\n => {x,y,z : a}\n -> x === y\n -> x === 0 * z + y\npsum0 prf = Calc $\n |~ x\n ~~ y ... prf\n ~~ 0 + y ..< plusZeroLeftNeutral\n ~~ 0 * z + y ..< cong (+ y) multZeroLeftAbsorbs\n\n-- Multiplying a sum with a term preserves the evaluation result.\n0 pmult1 : SolvableRing a\n => (m : a)\n -> (p : Prod a as)\n -> (s : Sum a as)\n -> esum (mult1 (T m p) s) === (m * eprod p) * esum s\npmult1 m p [] = sym multZeroRightAbsorbs\npmult1 m p (T n q :: xs) = Calc $\n |~ (m * n) * (eprod (mult p q)) + esum (mult1 (T m p) xs)\n ~~ (m * n) * (eprod p * eprod q) + esum (mult1 (T m p) xs)\n ... cong (\\x => (m*n) * x + esum (mult1 (T m p) xs)) (pmult p q)\n ~~ (m * eprod p) * (n * eprod q) + esum (mult1 (T m p) xs)\n ..< cong (+ esum (mult1 (T m p) xs)) m1324\n ~~ (m * eprod p) * (n * eprod q) + (m * eprod p) * esum xs\n ... cong ((m * eprod p) * (n * eprod q) +) (pmult1 m p xs)\n ~~ (m * eprod p) * (n * eprod q + esum xs)\n ..< leftDistributive\n\n-- Multiplying two sums of terms preserves the evaluation result.\n0 pmult : SolvableRing a\n => (x,y : Sum a as)\n -> esum x * esum y === esum (mult x y)\npmult [] y = multZeroLeftAbsorbs\npmult (T n x :: xs) y = Calc $\n |~ (n * eprod x + esum xs) * esum y\n ~~ (n * eprod x) * esum y + esum xs * esum y\n ... rightDistributive\n ~~ (n * eprod x) * esum y + esum (mult xs y)\n ... cong ((n * eprod x) * esum y +) (pmult xs y)\n ~~ esum (mult1 (T n x) y) + esum (mult xs y)\n ..< cong (+ esum (mult xs y)) (pmult1 n x y)\n ~~ esum (add (mult1 (T n x) y) (mult xs y))\n ... padd (mult1 (T n x) y) (mult xs y)\n\n-- Evaluating a negated term is equivalent to negate the\n-- result of evaluating the term.\n0 pnegTerm : SolvableRing a\n => (x : Term a as)\n -> eterm (negTerm x) === neg (eterm x)\npnegTerm (T f p) = multNegLeft\n\n-- Evaluating a negated sum of terms is equivalent to negate the\n-- result of evaluating the sum of terms.\n0 pneg : SolvableRing a\n => (x : Sum a as)\n -> esum (negate x) === neg (esum x)\npneg [] = sym $ negZero\npneg (x :: y) = Calc $\n |~ eterm (negTerm x) + esum (negate y)\n ~~ neg (eterm x) + esum (negate y) ... cong (+ esum (negate y)) (pnegTerm x)\n ~~ neg (eterm x) + neg (esum y) ... cong (neg (eterm x) +) (pneg y)\n ~~ neg (eterm x + esum y) ..< negDistributes\n\n-- Removing zero values from a sum of terms does not\n-- affect the evaluation result.\n0 pnormSum : SolvableRing a\n => (s : Sum a as)\n -> esum (normSum s) === esum s\npnormSum [] = Refl\npnormSum (T f p :: y) with (isZero f)\n _ | Nothing = Calc $\n |~ f * eprod p + esum (normSum y)\n ~~ f * eprod p + esum y ... cong ((f * eprod p) +) (pnormSum y)\n\n _ | Just refl = Calc $\n |~ esum (normSum y)\n ~~ esum y ... pnormSum y\n ~~ 0 + esum y ..< plusZeroLeftNeutral\n ~~ 0 * eprod p + esum y ..< cong (+ esum y) multZeroLeftAbsorbs\n ~~ f * eprod p + esum y ..< cong (\\x => x * eprod p + esum y) refl\n\n-- Evaluating an expression gives the same result as\n-- evaluating its normalized form.\n0 pnorm : SolvableRing a\n => (e : Expr a as)\n -> eval e === esum (norm e)\npnorm (Lit n) = Calc $\n |~ n\n ~~ n * 1 ..< multOneRightNeutral\n ~~ n * eprod (one {as}) ..< cong (n *) (pone as)\n ~~ n * eprod (one {as}) + 0 ..< plusZeroRightNeutral\n\npnorm (Var x y) = Calc $\n |~ x\n ~~ eprod (fromVar y) ..< pvar as y\n ~~ 1 * eprod (fromVar y) ..< multOneLeftNeutral\n ~~ 1 * eprod (fromVar y) + 0 ..< plusZeroRightNeutral\n\npnorm (Neg x) = Calc $\n |~ neg (eval x)\n ~~ neg (esum (norm x)) ... cong neg (pnorm x)\n ~~ esum (negate (norm x)) ..< pneg (norm x)\n\npnorm (Plus x y) = Calc $\n |~ eval x + eval y\n ~~ esum (norm x) + eval y\n ... cong (+ eval y) (pnorm x)\n ~~ esum (norm x) + esum (norm y)\n ... cong (esum (norm x) +) (pnorm y)\n ~~ esum (add (norm x) (norm y))\n ... padd _ _\n\npnorm (Mult x y) = Calc $\n |~ eval x * eval y\n ~~ esum (norm x) * eval y\n ... cong (* eval y) (pnorm x)\n ~~ esum (norm x) * esum (norm y)\n ... cong (esum (norm x) *) (pnorm y)\n ~~ esum (mult (norm x) (norm y))\n ... Sum.pmult _ _\n\npnorm (Minus x y) = Calc $\n |~ eval x - eval y\n ~~ eval x + neg (eval y)\n ... minusIsPlusNeg\n ~~ esum (norm x) + neg (eval y)\n ... cong (+ neg (eval y)) (pnorm x)\n ~~ esum (norm x) + neg (esum (norm y))\n ... cong (\\v => esum (norm x) + neg v) (pnorm y)\n ~~ esum (norm x) + esum (negate (norm y))\n ..< cong (esum (norm x) +) (pneg (norm y))\n ~~ esum (add (norm x) (negate (norm y)))\n ... padd _ _\n\n-- Evaluating an expression gives the same result as\n-- evaluating its normalized form.\n0 pnormalize : SolvableRing a\n => (e : Expr a as)\n -> eval e === esum (normalize e)\npnormalize e = Calc $\n |~ eval e\n ~~ esum (norm e) ... pnorm e\n ~~ esum (normSum (norm e)) ..< pnormSum (norm e)\n\n--------------------------------------------------------------------------------\n-- Solver\n--------------------------------------------------------------------------------\n\n||| Given a list `as` of variables and two arithmetic expressions\n||| over these variables, if the expressions are converted\n||| to the same normal form, evaluating them gives the same\n||| result.\n|||\n||| This simple fact allows us to conveniently and quickly\n||| proof arithmetic equalities required in other parts of\n||| our code. For instance:\n|||\n||| ```idris example\n||| 0 binom1 : {x,y : Bits8}\n||| -> (x + y) * (x + y) === x * x + 2 * x * y + y * y\n||| binom1 = solve [x,y]\n||| ((x .+. y) * (x .+. y))\n||| (x .*. x + 2 *. x *. y + y .*. y)\n||| ```\nexport\n0 solve : SolvableRing a\n => (as : List a)\n -> (e1,e2 : Expr a as)\n -> (prf : normalize e1 === normalize e2)\n => eval e1 === eval e2\nsolve _ e1 e2 = Calc $\n |~ eval e1\n ~~ esum (normalize e1) ...(pnormalize e1)\n ~~ esum (normalize e2) ...(cong esum prf)\n ~~ eval e2 ..<(pnormalize e2)\n\n--------------------------------------------------------------------------------\n-- Examples\n--------------------------------------------------------------------------------\n\n0 binom1 : {x,y : Bits8} -> (x + y) * (x + y) === x * x + 2 * x * y + y * y\nbinom1 = solve [x,y]\n ((x .+. y) * (x .+. y))\n (x .*. x + 2 *. x *. y + y .*. y)\n\n0 binom2 : {x,y : Bits8} -> (x - y) * (x - y) === x * x - 2 * x * y + y * y\nbinom2 = solve [x,y]\n ((x .-. y) * (x .-. y))\n (x .*. x - 2 *. x *. y + y .*. y)\n\n0 binom3 : {x,y : Bits8} -> (x + y) * (x - y) === x * x - y * y\nbinom3 = solve [x,y] ((x .+. y) * (x .-. y)) (x .*. x - y .*. y)\n", "meta": {"hexsha": "2758167aa717bf47d5d61e20bbf6e78d0e3330a4", "size": 11478, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Algebra/Solver/Ring/Sum.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/Solver/Ring/Sum.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/Solver/Ring/Sum.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": 34.4684684685, "max_line_length": 80, "alphanum_fraction": 0.4926816519, "num_tokens": 3849, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339837155239, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.5528955506946802}}
{"text": "\ndata Vect : (n:Nat) -> a -> Type where \n Nil : Vect Z a \n Cons : (head : a ) -> (tail : Vect k a) -> Vect (S k) a\n", "meta": {"hexsha": "a2df02b2f40d913d9ff643fb9bd690dd9aef5a91", "size": 117, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "vector_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": "vector_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": "vector_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": 23.4, "max_line_length": 57, "alphanum_fraction": 0.4871794872, "num_tokens": 46, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8933093946927837, "lm_q2_score": 0.6187804407739559, "lm_q1q2_score": 0.5527623809955164}}
{"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)))))))\nTy96 : Type\nTy96 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty96 : Ty96\nempty96 = \\ _, empty, _ => empty\n\narr96 : Ty96 -> Ty96 -> Ty96\narr96 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon96 : Type\nCon96 = (Con96 : Type)\n ->(nil : Con96)\n ->(snoc : Con96 -> Ty96 -> Con96)\n -> Con96\n\nnil96 : Con96\nnil96 = \\ con, nil96, snoc => nil96\n\nsnoc96 : Con96 -> Ty96 -> Con96\nsnoc96 = \\ g, a, con, nil96, snoc96 => snoc96 (g con nil96 snoc96) a\n\nVar96 : Con96 -> Ty96 -> Type\nVar96 = \\ g, a =>\n (Var96 : Con96 -> Ty96 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var96 (snoc96 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var96 g a -> Var96 (snoc96 g b) a)\n -> Var96 g a\n\nvz96 : {g : _}-> {a : _} -> Var96 (snoc96 g a) a\nvz96 = \\ var, vz96, vs => vz96 _ _\n\nvs96 : {g : _} -> {B : _} -> {a : _} -> Var96 g a -> Var96 (snoc96 g B) a\nvs96 = \\ x, var, vz96, vs96 => vs96 _ _ _ (x var vz96 vs96)\n\nTm96 : Con96 -> Ty96 -> Type\nTm96 = \\ g, a =>\n (Tm96 : Con96 -> Ty96 -> Type)\n -> (var : (g : _) -> (a : _) -> Var96 g a -> Tm96 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm96 (snoc96 g a) B -> Tm96 g (arr96 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm96 g (arr96 a B) -> Tm96 g a -> Tm96 g B)\n -> Tm96 g a\n\nvar96 : {g : _} -> {a : _} -> Var96 g a -> Tm96 g a\nvar96 = \\ x, tm, var96, lam, app => var96 _ _ x\n\nlam96 : {g : _} -> {a : _} -> {B : _} -> Tm96 (snoc96 g a) B -> Tm96 g (arr96 a B)\nlam96 = \\ t, tm, var96, lam96, app => lam96 _ _ _ (t tm var96 lam96 app)\n\napp96 : {g:_}->{a:_}->{B:_} -> Tm96 g (arr96 a B) -> Tm96 g a -> Tm96 g B\napp96 = \\ t, u, tm, var96, lam96, app96 => app96 _ _ _ (t tm var96 lam96 app96) (u tm var96 lam96 app96)\n\nv096 : {g:_}->{a:_} -> Tm96 (snoc96 g a) a\nv096 = var96 vz96\n\nv196 : {g:_}->{a:_}-> {B:_}-> Tm96 (snoc96 (snoc96 g a) B) a\nv196 = var96 (vs96 vz96)\n\nv296 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm96 (snoc96 (snoc96 (snoc96 g a) B) C) a\nv296 = var96 (vs96 (vs96 vz96))\n\nv396 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm96 (snoc96 (snoc96 (snoc96 (snoc96 g a) B) C) D) a\nv396 = var96 (vs96 (vs96 (vs96 vz96)))\n\nv496 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm96 (snoc96 (snoc96 (snoc96 (snoc96 (snoc96 g a) B) C) D) E) a\nv496 = var96 (vs96 (vs96 (vs96 (vs96 vz96))))\n\ntest96 : {g:_}-> {a:_} -> Tm96 g (arr96 (arr96 a a) (arr96 a a))\ntest96 = lam96 (lam96 (app96 v196 (app96 v196 (app96 v196 (app96 v196 (app96 v196 (app96 v196 v096)))))))\nTy97 : Type\nTy97 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty97 : Ty97\nempty97 = \\ _, empty, _ => empty\n\narr97 : Ty97 -> Ty97 -> Ty97\narr97 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon97 : Type\nCon97 = (Con97 : Type)\n ->(nil : Con97)\n ->(snoc : Con97 -> Ty97 -> Con97)\n -> Con97\n\nnil97 : Con97\nnil97 = \\ con, nil97, snoc => nil97\n\nsnoc97 : Con97 -> Ty97 -> Con97\nsnoc97 = \\ g, a, con, nil97, snoc97 => snoc97 (g con nil97 snoc97) a\n\nVar97 : Con97 -> Ty97 -> Type\nVar97 = \\ g, a =>\n (Var97 : Con97 -> Ty97 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var97 (snoc97 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var97 g a -> Var97 (snoc97 g b) a)\n -> Var97 g a\n\nvz97 : {g : _}-> {a : _} -> Var97 (snoc97 g a) a\nvz97 = \\ var, vz97, vs => vz97 _ _\n\nvs97 : {g : _} -> {B : _} -> {a : _} -> Var97 g a -> Var97 (snoc97 g B) a\nvs97 = \\ x, var, vz97, vs97 => vs97 _ _ _ (x var vz97 vs97)\n\nTm97 : Con97 -> Ty97 -> Type\nTm97 = \\ g, a =>\n (Tm97 : Con97 -> Ty97 -> Type)\n -> (var : (g : _) -> (a : _) -> Var97 g a -> Tm97 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm97 (snoc97 g a) B -> Tm97 g (arr97 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm97 g (arr97 a B) -> Tm97 g a -> Tm97 g B)\n -> Tm97 g a\n\nvar97 : {g : _} -> {a : _} -> Var97 g a -> Tm97 g a\nvar97 = \\ x, tm, var97, lam, app => var97 _ _ x\n\nlam97 : {g : _} -> {a : _} -> {B : _} -> Tm97 (snoc97 g a) B -> Tm97 g (arr97 a B)\nlam97 = \\ t, tm, var97, lam97, app => lam97 _ _ _ (t tm var97 lam97 app)\n\napp97 : {g:_}->{a:_}->{B:_} -> Tm97 g (arr97 a B) -> Tm97 g a -> Tm97 g B\napp97 = \\ t, u, tm, var97, lam97, app97 => app97 _ _ _ (t tm var97 lam97 app97) (u tm var97 lam97 app97)\n\nv097 : {g:_}->{a:_} -> Tm97 (snoc97 g a) a\nv097 = var97 vz97\n\nv197 : {g:_}->{a:_}-> {B:_}-> Tm97 (snoc97 (snoc97 g a) B) a\nv197 = var97 (vs97 vz97)\n\nv297 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm97 (snoc97 (snoc97 (snoc97 g a) B) C) a\nv297 = var97 (vs97 (vs97 vz97))\n\nv397 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm97 (snoc97 (snoc97 (snoc97 (snoc97 g a) B) C) D) a\nv397 = var97 (vs97 (vs97 (vs97 vz97)))\n\nv497 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm97 (snoc97 (snoc97 (snoc97 (snoc97 (snoc97 g a) B) C) D) E) a\nv497 = var97 (vs97 (vs97 (vs97 (vs97 vz97))))\n\ntest97 : {g:_}-> {a:_} -> Tm97 g (arr97 (arr97 a a) (arr97 a a))\ntest97 = lam97 (lam97 (app97 v197 (app97 v197 (app97 v197 (app97 v197 (app97 v197 (app97 v197 v097)))))))\nTy98 : Type\nTy98 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty98 : Ty98\nempty98 = \\ _, empty, _ => empty\n\narr98 : Ty98 -> Ty98 -> Ty98\narr98 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon98 : Type\nCon98 = (Con98 : Type)\n ->(nil : Con98)\n ->(snoc : Con98 -> Ty98 -> Con98)\n -> Con98\n\nnil98 : Con98\nnil98 = \\ con, nil98, snoc => nil98\n\nsnoc98 : Con98 -> Ty98 -> Con98\nsnoc98 = \\ g, a, con, nil98, snoc98 => snoc98 (g con nil98 snoc98) a\n\nVar98 : Con98 -> Ty98 -> Type\nVar98 = \\ g, a =>\n (Var98 : Con98 -> Ty98 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var98 (snoc98 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var98 g a -> Var98 (snoc98 g b) a)\n -> Var98 g a\n\nvz98 : {g : _}-> {a : _} -> Var98 (snoc98 g a) a\nvz98 = \\ var, vz98, vs => vz98 _ _\n\nvs98 : {g : _} -> {B : _} -> {a : _} -> Var98 g a -> Var98 (snoc98 g B) a\nvs98 = \\ x, var, vz98, vs98 => vs98 _ _ _ (x var vz98 vs98)\n\nTm98 : Con98 -> Ty98 -> Type\nTm98 = \\ g, a =>\n (Tm98 : Con98 -> Ty98 -> Type)\n -> (var : (g : _) -> (a : _) -> Var98 g a -> Tm98 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm98 (snoc98 g a) B -> Tm98 g (arr98 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm98 g (arr98 a B) -> Tm98 g a -> Tm98 g B)\n -> Tm98 g a\n\nvar98 : {g : _} -> {a : _} -> Var98 g a -> Tm98 g a\nvar98 = \\ x, tm, var98, lam, app => var98 _ _ x\n\nlam98 : {g : _} -> {a : _} -> {B : _} -> Tm98 (snoc98 g a) B -> Tm98 g (arr98 a B)\nlam98 = \\ t, tm, var98, lam98, app => lam98 _ _ _ (t tm var98 lam98 app)\n\napp98 : {g:_}->{a:_}->{B:_} -> Tm98 g (arr98 a B) -> Tm98 g a -> Tm98 g B\napp98 = \\ t, u, tm, var98, lam98, app98 => app98 _ _ _ (t tm var98 lam98 app98) (u tm var98 lam98 app98)\n\nv098 : {g:_}->{a:_} -> Tm98 (snoc98 g a) a\nv098 = var98 vz98\n\nv198 : {g:_}->{a:_}-> {B:_}-> Tm98 (snoc98 (snoc98 g a) B) a\nv198 = var98 (vs98 vz98)\n\nv298 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm98 (snoc98 (snoc98 (snoc98 g a) B) C) a\nv298 = var98 (vs98 (vs98 vz98))\n\nv398 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm98 (snoc98 (snoc98 (snoc98 (snoc98 g a) B) C) D) a\nv398 = var98 (vs98 (vs98 (vs98 vz98)))\n\nv498 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm98 (snoc98 (snoc98 (snoc98 (snoc98 (snoc98 g a) B) C) D) E) a\nv498 = var98 (vs98 (vs98 (vs98 (vs98 vz98))))\n\ntest98 : {g:_}-> {a:_} -> Tm98 g (arr98 (arr98 a a) (arr98 a a))\ntest98 = lam98 (lam98 (app98 v198 (app98 v198 (app98 v198 (app98 v198 (app98 v198 (app98 v198 v098)))))))\nTy99 : Type\nTy99 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty99 : Ty99\nempty99 = \\ _, empty, _ => empty\n\narr99 : Ty99 -> Ty99 -> Ty99\narr99 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon99 : Type\nCon99 = (Con99 : Type)\n ->(nil : Con99)\n ->(snoc : Con99 -> Ty99 -> Con99)\n -> Con99\n\nnil99 : Con99\nnil99 = \\ con, nil99, snoc => nil99\n\nsnoc99 : Con99 -> Ty99 -> Con99\nsnoc99 = \\ g, a, con, nil99, snoc99 => snoc99 (g con nil99 snoc99) a\n\nVar99 : Con99 -> Ty99 -> Type\nVar99 = \\ g, a =>\n (Var99 : Con99 -> Ty99 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var99 (snoc99 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var99 g a -> Var99 (snoc99 g b) a)\n -> Var99 g a\n\nvz99 : {g : _}-> {a : _} -> Var99 (snoc99 g a) a\nvz99 = \\ var, vz99, vs => vz99 _ _\n\nvs99 : {g : _} -> {B : _} -> {a : _} -> Var99 g a -> Var99 (snoc99 g B) a\nvs99 = \\ x, var, vz99, vs99 => vs99 _ _ _ (x var vz99 vs99)\n\nTm99 : Con99 -> Ty99 -> Type\nTm99 = \\ g, a =>\n (Tm99 : Con99 -> Ty99 -> Type)\n -> (var : (g : _) -> (a : _) -> Var99 g a -> Tm99 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm99 (snoc99 g a) B -> Tm99 g (arr99 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm99 g (arr99 a B) -> Tm99 g a -> Tm99 g B)\n -> Tm99 g a\n\nvar99 : {g : _} -> {a : _} -> Var99 g a -> Tm99 g a\nvar99 = \\ x, tm, var99, lam, app => var99 _ _ x\n\nlam99 : {g : _} -> {a : _} -> {B : _} -> Tm99 (snoc99 g a) B -> Tm99 g (arr99 a B)\nlam99 = \\ t, tm, var99, lam99, app => lam99 _ _ _ (t tm var99 lam99 app)\n\napp99 : {g:_}->{a:_}->{B:_} -> Tm99 g (arr99 a B) -> Tm99 g a -> Tm99 g B\napp99 = \\ t, u, tm, var99, lam99, app99 => app99 _ _ _ (t tm var99 lam99 app99) (u tm var99 lam99 app99)\n\nv099 : {g:_}->{a:_} -> Tm99 (snoc99 g a) a\nv099 = var99 vz99\n\nv199 : {g:_}->{a:_}-> {B:_}-> Tm99 (snoc99 (snoc99 g a) B) a\nv199 = var99 (vs99 vz99)\n\nv299 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm99 (snoc99 (snoc99 (snoc99 g a) B) C) a\nv299 = var99 (vs99 (vs99 vz99))\n\nv399 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm99 (snoc99 (snoc99 (snoc99 (snoc99 g a) B) C) D) a\nv399 = var99 (vs99 (vs99 (vs99 vz99)))\n\nv499 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm99 (snoc99 (snoc99 (snoc99 (snoc99 (snoc99 g a) B) C) D) E) a\nv499 = var99 (vs99 (vs99 (vs99 (vs99 vz99))))\n\ntest99 : {g:_}-> {a:_} -> Tm99 g (arr99 (arr99 a a) (arr99 a a))\ntest99 = lam99 (lam99 (app99 v199 (app99 v199 (app99 v199 (app99 v199 (app99 v199 (app99 v199 v099)))))))\nTy100 : Type\nTy100 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty100 : Ty100\nempty100 = \\ _, empty, _ => empty\n\narr100 : Ty100 -> Ty100 -> Ty100\narr100 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon100 : Type\nCon100 = (Con100 : Type)\n ->(nil : Con100)\n ->(snoc : Con100 -> Ty100 -> Con100)\n -> Con100\n\nnil100 : Con100\nnil100 = \\ con, nil100, snoc => nil100\n\nsnoc100 : Con100 -> Ty100 -> Con100\nsnoc100 = \\ g, a, con, nil100, snoc100 => snoc100 (g con nil100 snoc100) a\n\nVar100 : Con100 -> Ty100 -> Type\nVar100 = \\ g, a =>\n (Var100 : Con100 -> Ty100 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var100 (snoc100 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var100 g a -> Var100 (snoc100 g b) a)\n -> Var100 g a\n\nvz100 : {g : _}-> {a : _} -> Var100 (snoc100 g a) a\nvz100 = \\ var, vz100, vs => vz100 _ _\n\nvs100 : {g : _} -> {B : _} -> {a : _} -> Var100 g a -> Var100 (snoc100 g B) a\nvs100 = \\ x, var, vz100, vs100 => vs100 _ _ _ (x var vz100 vs100)\n\nTm100 : Con100 -> Ty100 -> Type\nTm100 = \\ g, a =>\n (Tm100 : Con100 -> Ty100 -> Type)\n -> (var : (g : _) -> (a : _) -> Var100 g a -> Tm100 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm100 (snoc100 g a) B -> Tm100 g (arr100 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm100 g (arr100 a B) -> Tm100 g a -> Tm100 g B)\n -> Tm100 g a\n\nvar100 : {g : _} -> {a : _} -> Var100 g a -> Tm100 g a\nvar100 = \\ x, tm, var100, lam, app => var100 _ _ x\n\nlam100 : {g : _} -> {a : _} -> {B : _} -> Tm100 (snoc100 g a) B -> Tm100 g (arr100 a B)\nlam100 = \\ t, tm, var100, lam100, app => lam100 _ _ _ (t tm var100 lam100 app)\n\napp100 : {g:_}->{a:_}->{B:_} -> Tm100 g (arr100 a B) -> Tm100 g a -> Tm100 g B\napp100 = \\ t, u, tm, var100, lam100, app100 => app100 _ _ _ (t tm var100 lam100 app100) (u tm var100 lam100 app100)\n\nv0100 : {g:_}->{a:_} -> Tm100 (snoc100 g a) a\nv0100 = var100 vz100\n\nv1100 : {g:_}->{a:_}-> {B:_}-> Tm100 (snoc100 (snoc100 g a) B) a\nv1100 = var100 (vs100 vz100)\n\nv2100 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm100 (snoc100 (snoc100 (snoc100 g a) B) C) a\nv2100 = var100 (vs100 (vs100 vz100))\n\nv3100 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm100 (snoc100 (snoc100 (snoc100 (snoc100 g a) B) C) D) a\nv3100 = var100 (vs100 (vs100 (vs100 vz100)))\n\nv4100 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm100 (snoc100 (snoc100 (snoc100 (snoc100 (snoc100 g a) B) C) D) E) a\nv4100 = var100 (vs100 (vs100 (vs100 (vs100 vz100))))\n\ntest100 : {g:_}-> {a:_} -> Tm100 g (arr100 (arr100 a a) (arr100 a a))\ntest100 = lam100 (lam100 (app100 v1100 (app100 v1100 (app100 v1100 (app100 v1100 (app100 v1100 (app100 v1100 v0100)))))))\nTy101 : Type\nTy101 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty101 : Ty101\nempty101 = \\ _, empty, _ => empty\n\narr101 : Ty101 -> Ty101 -> Ty101\narr101 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon101 : Type\nCon101 = (Con101 : Type)\n ->(nil : Con101)\n ->(snoc : Con101 -> Ty101 -> Con101)\n -> Con101\n\nnil101 : Con101\nnil101 = \\ con, nil101, snoc => nil101\n\nsnoc101 : Con101 -> Ty101 -> Con101\nsnoc101 = \\ g, a, con, nil101, snoc101 => snoc101 (g con nil101 snoc101) a\n\nVar101 : Con101 -> Ty101 -> Type\nVar101 = \\ g, a =>\n (Var101 : Con101 -> Ty101 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var101 (snoc101 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var101 g a -> Var101 (snoc101 g b) a)\n -> Var101 g a\n\nvz101 : {g : _}-> {a : _} -> Var101 (snoc101 g a) a\nvz101 = \\ var, vz101, vs => vz101 _ _\n\nvs101 : {g : _} -> {B : _} -> {a : _} -> Var101 g a -> Var101 (snoc101 g B) a\nvs101 = \\ x, var, vz101, vs101 => vs101 _ _ _ (x var vz101 vs101)\n\nTm101 : Con101 -> Ty101 -> Type\nTm101 = \\ g, a =>\n (Tm101 : Con101 -> Ty101 -> Type)\n -> (var : (g : _) -> (a : _) -> Var101 g a -> Tm101 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm101 (snoc101 g a) B -> Tm101 g (arr101 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm101 g (arr101 a B) -> Tm101 g a -> Tm101 g B)\n -> Tm101 g a\n\nvar101 : {g : _} -> {a : _} -> Var101 g a -> Tm101 g a\nvar101 = \\ x, tm, var101, lam, app => var101 _ _ x\n\nlam101 : {g : _} -> {a : _} -> {B : _} -> Tm101 (snoc101 g a) B -> Tm101 g (arr101 a B)\nlam101 = \\ t, tm, var101, lam101, app => lam101 _ _ _ (t tm var101 lam101 app)\n\napp101 : {g:_}->{a:_}->{B:_} -> Tm101 g (arr101 a B) -> Tm101 g a -> Tm101 g B\napp101 = \\ t, u, tm, var101, lam101, app101 => app101 _ _ _ (t tm var101 lam101 app101) (u tm var101 lam101 app101)\n\nv0101 : {g:_}->{a:_} -> Tm101 (snoc101 g a) a\nv0101 = var101 vz101\n\nv1101 : {g:_}->{a:_}-> {B:_}-> Tm101 (snoc101 (snoc101 g a) B) a\nv1101 = var101 (vs101 vz101)\n\nv2101 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm101 (snoc101 (snoc101 (snoc101 g a) B) C) a\nv2101 = var101 (vs101 (vs101 vz101))\n\nv3101 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm101 (snoc101 (snoc101 (snoc101 (snoc101 g a) B) C) D) a\nv3101 = var101 (vs101 (vs101 (vs101 vz101)))\n\nv4101 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm101 (snoc101 (snoc101 (snoc101 (snoc101 (snoc101 g a) B) C) D) E) a\nv4101 = var101 (vs101 (vs101 (vs101 (vs101 vz101))))\n\ntest101 : {g:_}-> {a:_} -> Tm101 g (arr101 (arr101 a a) (arr101 a a))\ntest101 = lam101 (lam101 (app101 v1101 (app101 v1101 (app101 v1101 (app101 v1101 (app101 v1101 (app101 v1101 v0101)))))))\nTy102 : Type\nTy102 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty102 : Ty102\nempty102 = \\ _, empty, _ => empty\n\narr102 : Ty102 -> Ty102 -> Ty102\narr102 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon102 : Type\nCon102 = (Con102 : Type)\n ->(nil : Con102)\n ->(snoc : Con102 -> Ty102 -> Con102)\n -> Con102\n\nnil102 : Con102\nnil102 = \\ con, nil102, snoc => nil102\n\nsnoc102 : Con102 -> Ty102 -> Con102\nsnoc102 = \\ g, a, con, nil102, snoc102 => snoc102 (g con nil102 snoc102) a\n\nVar102 : Con102 -> Ty102 -> Type\nVar102 = \\ g, a =>\n (Var102 : Con102 -> Ty102 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var102 (snoc102 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var102 g a -> Var102 (snoc102 g b) a)\n -> Var102 g a\n\nvz102 : {g : _}-> {a : _} -> Var102 (snoc102 g a) a\nvz102 = \\ var, vz102, vs => vz102 _ _\n\nvs102 : {g : _} -> {B : _} -> {a : _} -> Var102 g a -> Var102 (snoc102 g B) a\nvs102 = \\ x, var, vz102, vs102 => vs102 _ _ _ (x var vz102 vs102)\n\nTm102 : Con102 -> Ty102 -> Type\nTm102 = \\ g, a =>\n (Tm102 : Con102 -> Ty102 -> Type)\n -> (var : (g : _) -> (a : _) -> Var102 g a -> Tm102 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm102 (snoc102 g a) B -> Tm102 g (arr102 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm102 g (arr102 a B) -> Tm102 g a -> Tm102 g B)\n -> Tm102 g a\n\nvar102 : {g : _} -> {a : _} -> Var102 g a -> Tm102 g a\nvar102 = \\ x, tm, var102, lam, app => var102 _ _ x\n\nlam102 : {g : _} -> {a : _} -> {B : _} -> Tm102 (snoc102 g a) B -> Tm102 g (arr102 a B)\nlam102 = \\ t, tm, var102, lam102, app => lam102 _ _ _ (t tm var102 lam102 app)\n\napp102 : {g:_}->{a:_}->{B:_} -> Tm102 g (arr102 a B) -> Tm102 g a -> Tm102 g B\napp102 = \\ t, u, tm, var102, lam102, app102 => app102 _ _ _ (t tm var102 lam102 app102) (u tm var102 lam102 app102)\n\nv0102 : {g:_}->{a:_} -> Tm102 (snoc102 g a) a\nv0102 = var102 vz102\n\nv1102 : {g:_}->{a:_}-> {B:_}-> Tm102 (snoc102 (snoc102 g a) B) a\nv1102 = var102 (vs102 vz102)\n\nv2102 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm102 (snoc102 (snoc102 (snoc102 g a) B) C) a\nv2102 = var102 (vs102 (vs102 vz102))\n\nv3102 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm102 (snoc102 (snoc102 (snoc102 (snoc102 g a) B) C) D) a\nv3102 = var102 (vs102 (vs102 (vs102 vz102)))\n\nv4102 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm102 (snoc102 (snoc102 (snoc102 (snoc102 (snoc102 g a) B) C) D) E) a\nv4102 = var102 (vs102 (vs102 (vs102 (vs102 vz102))))\n\ntest102 : {g:_}-> {a:_} -> Tm102 g (arr102 (arr102 a a) (arr102 a a))\ntest102 = lam102 (lam102 (app102 v1102 (app102 v1102 (app102 v1102 (app102 v1102 (app102 v1102 (app102 v1102 v0102)))))))\nTy103 : Type\nTy103 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty103 : Ty103\nempty103 = \\ _, empty, _ => empty\n\narr103 : Ty103 -> Ty103 -> Ty103\narr103 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon103 : Type\nCon103 = (Con103 : Type)\n ->(nil : Con103)\n ->(snoc : Con103 -> Ty103 -> Con103)\n -> Con103\n\nnil103 : Con103\nnil103 = \\ con, nil103, snoc => nil103\n\nsnoc103 : Con103 -> Ty103 -> Con103\nsnoc103 = \\ g, a, con, nil103, snoc103 => snoc103 (g con nil103 snoc103) a\n\nVar103 : Con103 -> Ty103 -> Type\nVar103 = \\ g, a =>\n (Var103 : Con103 -> Ty103 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var103 (snoc103 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var103 g a -> Var103 (snoc103 g b) a)\n -> Var103 g a\n\nvz103 : {g : _}-> {a : _} -> Var103 (snoc103 g a) a\nvz103 = \\ var, vz103, vs => vz103 _ _\n\nvs103 : {g : _} -> {B : _} -> {a : _} -> Var103 g a -> Var103 (snoc103 g B) a\nvs103 = \\ x, var, vz103, vs103 => vs103 _ _ _ (x var vz103 vs103)\n\nTm103 : Con103 -> Ty103 -> Type\nTm103 = \\ g, a =>\n (Tm103 : Con103 -> Ty103 -> Type)\n -> (var : (g : _) -> (a : _) -> Var103 g a -> Tm103 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm103 (snoc103 g a) B -> Tm103 g (arr103 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm103 g (arr103 a B) -> Tm103 g a -> Tm103 g B)\n -> Tm103 g a\n\nvar103 : {g : _} -> {a : _} -> Var103 g a -> Tm103 g a\nvar103 = \\ x, tm, var103, lam, app => var103 _ _ x\n\nlam103 : {g : _} -> {a : _} -> {B : _} -> Tm103 (snoc103 g a) B -> Tm103 g (arr103 a B)\nlam103 = \\ t, tm, var103, lam103, app => lam103 _ _ _ (t tm var103 lam103 app)\n\napp103 : {g:_}->{a:_}->{B:_} -> Tm103 g (arr103 a B) -> Tm103 g a -> Tm103 g B\napp103 = \\ t, u, tm, var103, lam103, app103 => app103 _ _ _ (t tm var103 lam103 app103) (u tm var103 lam103 app103)\n\nv0103 : {g:_}->{a:_} -> Tm103 (snoc103 g a) a\nv0103 = var103 vz103\n\nv1103 : {g:_}->{a:_}-> {B:_}-> Tm103 (snoc103 (snoc103 g a) B) a\nv1103 = var103 (vs103 vz103)\n\nv2103 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm103 (snoc103 (snoc103 (snoc103 g a) B) C) a\nv2103 = var103 (vs103 (vs103 vz103))\n\nv3103 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm103 (snoc103 (snoc103 (snoc103 (snoc103 g a) B) C) D) a\nv3103 = var103 (vs103 (vs103 (vs103 vz103)))\n\nv4103 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm103 (snoc103 (snoc103 (snoc103 (snoc103 (snoc103 g a) B) C) D) E) a\nv4103 = var103 (vs103 (vs103 (vs103 (vs103 vz103))))\n\ntest103 : {g:_}-> {a:_} -> Tm103 g (arr103 (arr103 a a) (arr103 a a))\ntest103 = lam103 (lam103 (app103 v1103 (app103 v1103 (app103 v1103 (app103 v1103 (app103 v1103 (app103 v1103 v0103)))))))\nTy104 : Type\nTy104 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty104 : Ty104\nempty104 = \\ _, empty, _ => empty\n\narr104 : Ty104 -> Ty104 -> Ty104\narr104 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon104 : Type\nCon104 = (Con104 : Type)\n ->(nil : Con104)\n ->(snoc : Con104 -> Ty104 -> Con104)\n -> Con104\n\nnil104 : Con104\nnil104 = \\ con, nil104, snoc => nil104\n\nsnoc104 : Con104 -> Ty104 -> Con104\nsnoc104 = \\ g, a, con, nil104, snoc104 => snoc104 (g con nil104 snoc104) a\n\nVar104 : Con104 -> Ty104 -> Type\nVar104 = \\ g, a =>\n (Var104 : Con104 -> Ty104 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var104 (snoc104 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var104 g a -> Var104 (snoc104 g b) a)\n -> Var104 g a\n\nvz104 : {g : _}-> {a : _} -> Var104 (snoc104 g a) a\nvz104 = \\ var, vz104, vs => vz104 _ _\n\nvs104 : {g : _} -> {B : _} -> {a : _} -> Var104 g a -> Var104 (snoc104 g B) a\nvs104 = \\ x, var, vz104, vs104 => vs104 _ _ _ (x var vz104 vs104)\n\nTm104 : Con104 -> Ty104 -> Type\nTm104 = \\ g, a =>\n (Tm104 : Con104 -> Ty104 -> Type)\n -> (var : (g : _) -> (a : _) -> Var104 g a -> Tm104 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm104 (snoc104 g a) B -> Tm104 g (arr104 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm104 g (arr104 a B) -> Tm104 g a -> Tm104 g B)\n -> Tm104 g a\n\nvar104 : {g : _} -> {a : _} -> Var104 g a -> Tm104 g a\nvar104 = \\ x, tm, var104, lam, app => var104 _ _ x\n\nlam104 : {g : _} -> {a : _} -> {B : _} -> Tm104 (snoc104 g a) B -> Tm104 g (arr104 a B)\nlam104 = \\ t, tm, var104, lam104, app => lam104 _ _ _ (t tm var104 lam104 app)\n\napp104 : {g:_}->{a:_}->{B:_} -> Tm104 g (arr104 a B) -> Tm104 g a -> Tm104 g B\napp104 = \\ t, u, tm, var104, lam104, app104 => app104 _ _ _ (t tm var104 lam104 app104) (u tm var104 lam104 app104)\n\nv0104 : {g:_}->{a:_} -> Tm104 (snoc104 g a) a\nv0104 = var104 vz104\n\nv1104 : {g:_}->{a:_}-> {B:_}-> Tm104 (snoc104 (snoc104 g a) B) a\nv1104 = var104 (vs104 vz104)\n\nv2104 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm104 (snoc104 (snoc104 (snoc104 g a) B) C) a\nv2104 = var104 (vs104 (vs104 vz104))\n\nv3104 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm104 (snoc104 (snoc104 (snoc104 (snoc104 g a) B) C) D) a\nv3104 = var104 (vs104 (vs104 (vs104 vz104)))\n\nv4104 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm104 (snoc104 (snoc104 (snoc104 (snoc104 (snoc104 g a) B) C) D) E) a\nv4104 = var104 (vs104 (vs104 (vs104 (vs104 vz104))))\n\ntest104 : {g:_}-> {a:_} -> Tm104 g (arr104 (arr104 a a) (arr104 a a))\ntest104 = lam104 (lam104 (app104 v1104 (app104 v1104 (app104 v1104 (app104 v1104 (app104 v1104 (app104 v1104 v0104)))))))\nTy105 : Type\nTy105 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty105 : Ty105\nempty105 = \\ _, empty, _ => empty\n\narr105 : Ty105 -> Ty105 -> Ty105\narr105 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon105 : Type\nCon105 = (Con105 : Type)\n ->(nil : Con105)\n ->(snoc : Con105 -> Ty105 -> Con105)\n -> Con105\n\nnil105 : Con105\nnil105 = \\ con, nil105, snoc => nil105\n\nsnoc105 : Con105 -> Ty105 -> Con105\nsnoc105 = \\ g, a, con, nil105, snoc105 => snoc105 (g con nil105 snoc105) a\n\nVar105 : Con105 -> Ty105 -> Type\nVar105 = \\ g, a =>\n (Var105 : Con105 -> Ty105 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var105 (snoc105 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var105 g a -> Var105 (snoc105 g b) a)\n -> Var105 g a\n\nvz105 : {g : _}-> {a : _} -> Var105 (snoc105 g a) a\nvz105 = \\ var, vz105, vs => vz105 _ _\n\nvs105 : {g : _} -> {B : _} -> {a : _} -> Var105 g a -> Var105 (snoc105 g B) a\nvs105 = \\ x, var, vz105, vs105 => vs105 _ _ _ (x var vz105 vs105)\n\nTm105 : Con105 -> Ty105 -> Type\nTm105 = \\ g, a =>\n (Tm105 : Con105 -> Ty105 -> Type)\n -> (var : (g : _) -> (a : _) -> Var105 g a -> Tm105 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm105 (snoc105 g a) B -> Tm105 g (arr105 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm105 g (arr105 a B) -> Tm105 g a -> Tm105 g B)\n -> Tm105 g a\n\nvar105 : {g : _} -> {a : _} -> Var105 g a -> Tm105 g a\nvar105 = \\ x, tm, var105, lam, app => var105 _ _ x\n\nlam105 : {g : _} -> {a : _} -> {B : _} -> Tm105 (snoc105 g a) B -> Tm105 g (arr105 a B)\nlam105 = \\ t, tm, var105, lam105, app => lam105 _ _ _ (t tm var105 lam105 app)\n\napp105 : {g:_}->{a:_}->{B:_} -> Tm105 g (arr105 a B) -> Tm105 g a -> Tm105 g B\napp105 = \\ t, u, tm, var105, lam105, app105 => app105 _ _ _ (t tm var105 lam105 app105) (u tm var105 lam105 app105)\n\nv0105 : {g:_}->{a:_} -> Tm105 (snoc105 g a) a\nv0105 = var105 vz105\n\nv1105 : {g:_}->{a:_}-> {B:_}-> Tm105 (snoc105 (snoc105 g a) B) a\nv1105 = var105 (vs105 vz105)\n\nv2105 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm105 (snoc105 (snoc105 (snoc105 g a) B) C) a\nv2105 = var105 (vs105 (vs105 vz105))\n\nv3105 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm105 (snoc105 (snoc105 (snoc105 (snoc105 g a) B) C) D) a\nv3105 = var105 (vs105 (vs105 (vs105 vz105)))\n\nv4105 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm105 (snoc105 (snoc105 (snoc105 (snoc105 (snoc105 g a) B) C) D) E) a\nv4105 = var105 (vs105 (vs105 (vs105 (vs105 vz105))))\n\ntest105 : {g:_}-> {a:_} -> Tm105 g (arr105 (arr105 a a) (arr105 a a))\ntest105 = lam105 (lam105 (app105 v1105 (app105 v1105 (app105 v1105 (app105 v1105 (app105 v1105 (app105 v1105 v0105)))))))\nTy106 : Type\nTy106 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty106 : Ty106\nempty106 = \\ _, empty, _ => empty\n\narr106 : Ty106 -> Ty106 -> Ty106\narr106 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon106 : Type\nCon106 = (Con106 : Type)\n ->(nil : Con106)\n ->(snoc : Con106 -> Ty106 -> Con106)\n -> Con106\n\nnil106 : Con106\nnil106 = \\ con, nil106, snoc => nil106\n\nsnoc106 : Con106 -> Ty106 -> Con106\nsnoc106 = \\ g, a, con, nil106, snoc106 => snoc106 (g con nil106 snoc106) a\n\nVar106 : Con106 -> Ty106 -> Type\nVar106 = \\ g, a =>\n (Var106 : Con106 -> Ty106 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var106 (snoc106 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var106 g a -> Var106 (snoc106 g b) a)\n -> Var106 g a\n\nvz106 : {g : _}-> {a : _} -> Var106 (snoc106 g a) a\nvz106 = \\ var, vz106, vs => vz106 _ _\n\nvs106 : {g : _} -> {B : _} -> {a : _} -> Var106 g a -> Var106 (snoc106 g B) a\nvs106 = \\ x, var, vz106, vs106 => vs106 _ _ _ (x var vz106 vs106)\n\nTm106 : Con106 -> Ty106 -> Type\nTm106 = \\ g, a =>\n (Tm106 : Con106 -> Ty106 -> Type)\n -> (var : (g : _) -> (a : _) -> Var106 g a -> Tm106 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm106 (snoc106 g a) B -> Tm106 g (arr106 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm106 g (arr106 a B) -> Tm106 g a -> Tm106 g B)\n -> Tm106 g a\n\nvar106 : {g : _} -> {a : _} -> Var106 g a -> Tm106 g a\nvar106 = \\ x, tm, var106, lam, app => var106 _ _ x\n\nlam106 : {g : _} -> {a : _} -> {B : _} -> Tm106 (snoc106 g a) B -> Tm106 g (arr106 a B)\nlam106 = \\ t, tm, var106, lam106, app => lam106 _ _ _ (t tm var106 lam106 app)\n\napp106 : {g:_}->{a:_}->{B:_} -> Tm106 g (arr106 a B) -> Tm106 g a -> Tm106 g B\napp106 = \\ t, u, tm, var106, lam106, app106 => app106 _ _ _ (t tm var106 lam106 app106) (u tm var106 lam106 app106)\n\nv0106 : {g:_}->{a:_} -> Tm106 (snoc106 g a) a\nv0106 = var106 vz106\n\nv1106 : {g:_}->{a:_}-> {B:_}-> Tm106 (snoc106 (snoc106 g a) B) a\nv1106 = var106 (vs106 vz106)\n\nv2106 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm106 (snoc106 (snoc106 (snoc106 g a) B) C) a\nv2106 = var106 (vs106 (vs106 vz106))\n\nv3106 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm106 (snoc106 (snoc106 (snoc106 (snoc106 g a) B) C) D) a\nv3106 = var106 (vs106 (vs106 (vs106 vz106)))\n\nv4106 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm106 (snoc106 (snoc106 (snoc106 (snoc106 (snoc106 g a) B) C) D) E) a\nv4106 = var106 (vs106 (vs106 (vs106 (vs106 vz106))))\n\ntest106 : {g:_}-> {a:_} -> Tm106 g (arr106 (arr106 a a) (arr106 a a))\ntest106 = lam106 (lam106 (app106 v1106 (app106 v1106 (app106 v1106 (app106 v1106 (app106 v1106 (app106 v1106 v0106)))))))\nTy107 : Type\nTy107 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty107 : Ty107\nempty107 = \\ _, empty, _ => empty\n\narr107 : Ty107 -> Ty107 -> Ty107\narr107 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon107 : Type\nCon107 = (Con107 : Type)\n ->(nil : Con107)\n ->(snoc : Con107 -> Ty107 -> Con107)\n -> Con107\n\nnil107 : Con107\nnil107 = \\ con, nil107, snoc => nil107\n\nsnoc107 : Con107 -> Ty107 -> Con107\nsnoc107 = \\ g, a, con, nil107, snoc107 => snoc107 (g con nil107 snoc107) a\n\nVar107 : Con107 -> Ty107 -> Type\nVar107 = \\ g, a =>\n (Var107 : Con107 -> Ty107 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var107 (snoc107 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var107 g a -> Var107 (snoc107 g b) a)\n -> Var107 g a\n\nvz107 : {g : _}-> {a : _} -> Var107 (snoc107 g a) a\nvz107 = \\ var, vz107, vs => vz107 _ _\n\nvs107 : {g : _} -> {B : _} -> {a : _} -> Var107 g a -> Var107 (snoc107 g B) a\nvs107 = \\ x, var, vz107, vs107 => vs107 _ _ _ (x var vz107 vs107)\n\nTm107 : Con107 -> Ty107 -> Type\nTm107 = \\ g, a =>\n (Tm107 : Con107 -> Ty107 -> Type)\n -> (var : (g : _) -> (a : _) -> Var107 g a -> Tm107 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm107 (snoc107 g a) B -> Tm107 g (arr107 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm107 g (arr107 a B) -> Tm107 g a -> Tm107 g B)\n -> Tm107 g a\n\nvar107 : {g : _} -> {a : _} -> Var107 g a -> Tm107 g a\nvar107 = \\ x, tm, var107, lam, app => var107 _ _ x\n\nlam107 : {g : _} -> {a : _} -> {B : _} -> Tm107 (snoc107 g a) B -> Tm107 g (arr107 a B)\nlam107 = \\ t, tm, var107, lam107, app => lam107 _ _ _ (t tm var107 lam107 app)\n\napp107 : {g:_}->{a:_}->{B:_} -> Tm107 g (arr107 a B) -> Tm107 g a -> Tm107 g B\napp107 = \\ t, u, tm, var107, lam107, app107 => app107 _ _ _ (t tm var107 lam107 app107) (u tm var107 lam107 app107)\n\nv0107 : {g:_}->{a:_} -> Tm107 (snoc107 g a) a\nv0107 = var107 vz107\n\nv1107 : {g:_}->{a:_}-> {B:_}-> Tm107 (snoc107 (snoc107 g a) B) a\nv1107 = var107 (vs107 vz107)\n\nv2107 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm107 (snoc107 (snoc107 (snoc107 g a) B) C) a\nv2107 = var107 (vs107 (vs107 vz107))\n\nv3107 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm107 (snoc107 (snoc107 (snoc107 (snoc107 g a) B) C) D) a\nv3107 = var107 (vs107 (vs107 (vs107 vz107)))\n\nv4107 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm107 (snoc107 (snoc107 (snoc107 (snoc107 (snoc107 g a) B) C) D) E) a\nv4107 = var107 (vs107 (vs107 (vs107 (vs107 vz107))))\n\ntest107 : {g:_}-> {a:_} -> Tm107 g (arr107 (arr107 a a) (arr107 a a))\ntest107 = lam107 (lam107 (app107 v1107 (app107 v1107 (app107 v1107 (app107 v1107 (app107 v1107 (app107 v1107 v0107)))))))\nTy108 : Type\nTy108 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty108 : Ty108\nempty108 = \\ _, empty, _ => empty\n\narr108 : Ty108 -> Ty108 -> Ty108\narr108 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon108 : Type\nCon108 = (Con108 : Type)\n ->(nil : Con108)\n ->(snoc : Con108 -> Ty108 -> Con108)\n -> Con108\n\nnil108 : Con108\nnil108 = \\ con, nil108, snoc => nil108\n\nsnoc108 : Con108 -> Ty108 -> Con108\nsnoc108 = \\ g, a, con, nil108, snoc108 => snoc108 (g con nil108 snoc108) a\n\nVar108 : Con108 -> Ty108 -> Type\nVar108 = \\ g, a =>\n (Var108 : Con108 -> Ty108 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var108 (snoc108 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var108 g a -> Var108 (snoc108 g b) a)\n -> Var108 g a\n\nvz108 : {g : _}-> {a : _} -> Var108 (snoc108 g a) a\nvz108 = \\ var, vz108, vs => vz108 _ _\n\nvs108 : {g : _} -> {B : _} -> {a : _} -> Var108 g a -> Var108 (snoc108 g B) a\nvs108 = \\ x, var, vz108, vs108 => vs108 _ _ _ (x var vz108 vs108)\n\nTm108 : Con108 -> Ty108 -> Type\nTm108 = \\ g, a =>\n (Tm108 : Con108 -> Ty108 -> Type)\n -> (var : (g : _) -> (a : _) -> Var108 g a -> Tm108 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm108 (snoc108 g a) B -> Tm108 g (arr108 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm108 g (arr108 a B) -> Tm108 g a -> Tm108 g B)\n -> Tm108 g a\n\nvar108 : {g : _} -> {a : _} -> Var108 g a -> Tm108 g a\nvar108 = \\ x, tm, var108, lam, app => var108 _ _ x\n\nlam108 : {g : _} -> {a : _} -> {B : _} -> Tm108 (snoc108 g a) B -> Tm108 g (arr108 a B)\nlam108 = \\ t, tm, var108, lam108, app => lam108 _ _ _ (t tm var108 lam108 app)\n\napp108 : {g:_}->{a:_}->{B:_} -> Tm108 g (arr108 a B) -> Tm108 g a -> Tm108 g B\napp108 = \\ t, u, tm, var108, lam108, app108 => app108 _ _ _ (t tm var108 lam108 app108) (u tm var108 lam108 app108)\n\nv0108 : {g:_}->{a:_} -> Tm108 (snoc108 g a) a\nv0108 = var108 vz108\n\nv1108 : {g:_}->{a:_}-> {B:_}-> Tm108 (snoc108 (snoc108 g a) B) a\nv1108 = var108 (vs108 vz108)\n\nv2108 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm108 (snoc108 (snoc108 (snoc108 g a) B) C) a\nv2108 = var108 (vs108 (vs108 vz108))\n\nv3108 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm108 (snoc108 (snoc108 (snoc108 (snoc108 g a) B) C) D) a\nv3108 = var108 (vs108 (vs108 (vs108 vz108)))\n\nv4108 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm108 (snoc108 (snoc108 (snoc108 (snoc108 (snoc108 g a) B) C) D) E) a\nv4108 = var108 (vs108 (vs108 (vs108 (vs108 vz108))))\n\ntest108 : {g:_}-> {a:_} -> Tm108 g (arr108 (arr108 a a) (arr108 a a))\ntest108 = lam108 (lam108 (app108 v1108 (app108 v1108 (app108 v1108 (app108 v1108 (app108 v1108 (app108 v1108 v0108)))))))\nTy109 : Type\nTy109 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty109 : Ty109\nempty109 = \\ _, empty, _ => empty\n\narr109 : Ty109 -> Ty109 -> Ty109\narr109 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon109 : Type\nCon109 = (Con109 : Type)\n ->(nil : Con109)\n ->(snoc : Con109 -> Ty109 -> Con109)\n -> Con109\n\nnil109 : Con109\nnil109 = \\ con, nil109, snoc => nil109\n\nsnoc109 : Con109 -> Ty109 -> Con109\nsnoc109 = \\ g, a, con, nil109, snoc109 => snoc109 (g con nil109 snoc109) a\n\nVar109 : Con109 -> Ty109 -> Type\nVar109 = \\ g, a =>\n (Var109 : Con109 -> Ty109 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var109 (snoc109 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var109 g a -> Var109 (snoc109 g b) a)\n -> Var109 g a\n\nvz109 : {g : _}-> {a : _} -> Var109 (snoc109 g a) a\nvz109 = \\ var, vz109, vs => vz109 _ _\n\nvs109 : {g : _} -> {B : _} -> {a : _} -> Var109 g a -> Var109 (snoc109 g B) a\nvs109 = \\ x, var, vz109, vs109 => vs109 _ _ _ (x var vz109 vs109)\n\nTm109 : Con109 -> Ty109 -> Type\nTm109 = \\ g, a =>\n (Tm109 : Con109 -> Ty109 -> Type)\n -> (var : (g : _) -> (a : _) -> Var109 g a -> Tm109 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm109 (snoc109 g a) B -> Tm109 g (arr109 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm109 g (arr109 a B) -> Tm109 g a -> Tm109 g B)\n -> Tm109 g a\n\nvar109 : {g : _} -> {a : _} -> Var109 g a -> Tm109 g a\nvar109 = \\ x, tm, var109, lam, app => var109 _ _ x\n\nlam109 : {g : _} -> {a : _} -> {B : _} -> Tm109 (snoc109 g a) B -> Tm109 g (arr109 a B)\nlam109 = \\ t, tm, var109, lam109, app => lam109 _ _ _ (t tm var109 lam109 app)\n\napp109 : {g:_}->{a:_}->{B:_} -> Tm109 g (arr109 a B) -> Tm109 g a -> Tm109 g B\napp109 = \\ t, u, tm, var109, lam109, app109 => app109 _ _ _ (t tm var109 lam109 app109) (u tm var109 lam109 app109)\n\nv0109 : {g:_}->{a:_} -> Tm109 (snoc109 g a) a\nv0109 = var109 vz109\n\nv1109 : {g:_}->{a:_}-> {B:_}-> Tm109 (snoc109 (snoc109 g a) B) a\nv1109 = var109 (vs109 vz109)\n\nv2109 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm109 (snoc109 (snoc109 (snoc109 g a) B) C) a\nv2109 = var109 (vs109 (vs109 vz109))\n\nv3109 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm109 (snoc109 (snoc109 (snoc109 (snoc109 g a) B) C) D) a\nv3109 = var109 (vs109 (vs109 (vs109 vz109)))\n\nv4109 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm109 (snoc109 (snoc109 (snoc109 (snoc109 (snoc109 g a) B) C) D) E) a\nv4109 = var109 (vs109 (vs109 (vs109 (vs109 vz109))))\n\ntest109 : {g:_}-> {a:_} -> Tm109 g (arr109 (arr109 a a) (arr109 a a))\ntest109 = lam109 (lam109 (app109 v1109 (app109 v1109 (app109 v1109 (app109 v1109 (app109 v1109 (app109 v1109 v0109)))))))\nTy110 : Type\nTy110 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty110 : Ty110\nempty110 = \\ _, empty, _ => empty\n\narr110 : Ty110 -> Ty110 -> Ty110\narr110 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon110 : Type\nCon110 = (Con110 : Type)\n ->(nil : Con110)\n ->(snoc : Con110 -> Ty110 -> Con110)\n -> Con110\n\nnil110 : Con110\nnil110 = \\ con, nil110, snoc => nil110\n\nsnoc110 : Con110 -> Ty110 -> Con110\nsnoc110 = \\ g, a, con, nil110, snoc110 => snoc110 (g con nil110 snoc110) a\n\nVar110 : Con110 -> Ty110 -> Type\nVar110 = \\ g, a =>\n (Var110 : Con110 -> Ty110 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var110 (snoc110 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var110 g a -> Var110 (snoc110 g b) a)\n -> Var110 g a\n\nvz110 : {g : _}-> {a : _} -> Var110 (snoc110 g a) a\nvz110 = \\ var, vz110, vs => vz110 _ _\n\nvs110 : {g : _} -> {B : _} -> {a : _} -> Var110 g a -> Var110 (snoc110 g B) a\nvs110 = \\ x, var, vz110, vs110 => vs110 _ _ _ (x var vz110 vs110)\n\nTm110 : Con110 -> Ty110 -> Type\nTm110 = \\ g, a =>\n (Tm110 : Con110 -> Ty110 -> Type)\n -> (var : (g : _) -> (a : _) -> Var110 g a -> Tm110 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm110 (snoc110 g a) B -> Tm110 g (arr110 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm110 g (arr110 a B) -> Tm110 g a -> Tm110 g B)\n -> Tm110 g a\n\nvar110 : {g : _} -> {a : _} -> Var110 g a -> Tm110 g a\nvar110 = \\ x, tm, var110, lam, app => var110 _ _ x\n\nlam110 : {g : _} -> {a : _} -> {B : _} -> Tm110 (snoc110 g a) B -> Tm110 g (arr110 a B)\nlam110 = \\ t, tm, var110, lam110, app => lam110 _ _ _ (t tm var110 lam110 app)\n\napp110 : {g:_}->{a:_}->{B:_} -> Tm110 g (arr110 a B) -> Tm110 g a -> Tm110 g B\napp110 = \\ t, u, tm, var110, lam110, app110 => app110 _ _ _ (t tm var110 lam110 app110) (u tm var110 lam110 app110)\n\nv0110 : {g:_}->{a:_} -> Tm110 (snoc110 g a) a\nv0110 = var110 vz110\n\nv1110 : {g:_}->{a:_}-> {B:_}-> Tm110 (snoc110 (snoc110 g a) B) a\nv1110 = var110 (vs110 vz110)\n\nv2110 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm110 (snoc110 (snoc110 (snoc110 g a) B) C) a\nv2110 = var110 (vs110 (vs110 vz110))\n\nv3110 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm110 (snoc110 (snoc110 (snoc110 (snoc110 g a) B) C) D) a\nv3110 = var110 (vs110 (vs110 (vs110 vz110)))\n\nv4110 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm110 (snoc110 (snoc110 (snoc110 (snoc110 (snoc110 g a) B) C) D) E) a\nv4110 = var110 (vs110 (vs110 (vs110 (vs110 vz110))))\n\ntest110 : {g:_}-> {a:_} -> Tm110 g (arr110 (arr110 a a) (arr110 a a))\ntest110 = lam110 (lam110 (app110 v1110 (app110 v1110 (app110 v1110 (app110 v1110 (app110 v1110 (app110 v1110 v0110)))))))\nTy111 : Type\nTy111 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty111 : Ty111\nempty111 = \\ _, empty, _ => empty\n\narr111 : Ty111 -> Ty111 -> Ty111\narr111 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon111 : Type\nCon111 = (Con111 : Type)\n ->(nil : Con111)\n ->(snoc : Con111 -> Ty111 -> Con111)\n -> Con111\n\nnil111 : Con111\nnil111 = \\ con, nil111, snoc => nil111\n\nsnoc111 : Con111 -> Ty111 -> Con111\nsnoc111 = \\ g, a, con, nil111, snoc111 => snoc111 (g con nil111 snoc111) a\n\nVar111 : Con111 -> Ty111 -> Type\nVar111 = \\ g, a =>\n (Var111 : Con111 -> Ty111 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var111 (snoc111 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var111 g a -> Var111 (snoc111 g b) a)\n -> Var111 g a\n\nvz111 : {g : _}-> {a : _} -> Var111 (snoc111 g a) a\nvz111 = \\ var, vz111, vs => vz111 _ _\n\nvs111 : {g : _} -> {B : _} -> {a : _} -> Var111 g a -> Var111 (snoc111 g B) a\nvs111 = \\ x, var, vz111, vs111 => vs111 _ _ _ (x var vz111 vs111)\n\nTm111 : Con111 -> Ty111 -> Type\nTm111 = \\ g, a =>\n (Tm111 : Con111 -> Ty111 -> Type)\n -> (var : (g : _) -> (a : _) -> Var111 g a -> Tm111 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm111 (snoc111 g a) B -> Tm111 g (arr111 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm111 g (arr111 a B) -> Tm111 g a -> Tm111 g B)\n -> Tm111 g a\n\nvar111 : {g : _} -> {a : _} -> Var111 g a -> Tm111 g a\nvar111 = \\ x, tm, var111, lam, app => var111 _ _ x\n\nlam111 : {g : _} -> {a : _} -> {B : _} -> Tm111 (snoc111 g a) B -> Tm111 g (arr111 a B)\nlam111 = \\ t, tm, var111, lam111, app => lam111 _ _ _ (t tm var111 lam111 app)\n\napp111 : {g:_}->{a:_}->{B:_} -> Tm111 g (arr111 a B) -> Tm111 g a -> Tm111 g B\napp111 = \\ t, u, tm, var111, lam111, app111 => app111 _ _ _ (t tm var111 lam111 app111) (u tm var111 lam111 app111)\n\nv0111 : {g:_}->{a:_} -> Tm111 (snoc111 g a) a\nv0111 = var111 vz111\n\nv1111 : {g:_}->{a:_}-> {B:_}-> Tm111 (snoc111 (snoc111 g a) B) a\nv1111 = var111 (vs111 vz111)\n\nv2111 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm111 (snoc111 (snoc111 (snoc111 g a) B) C) a\nv2111 = var111 (vs111 (vs111 vz111))\n\nv3111 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm111 (snoc111 (snoc111 (snoc111 (snoc111 g a) B) C) D) a\nv3111 = var111 (vs111 (vs111 (vs111 vz111)))\n\nv4111 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm111 (snoc111 (snoc111 (snoc111 (snoc111 (snoc111 g a) B) C) D) E) a\nv4111 = var111 (vs111 (vs111 (vs111 (vs111 vz111))))\n\ntest111 : {g:_}-> {a:_} -> Tm111 g (arr111 (arr111 a a) (arr111 a a))\ntest111 = lam111 (lam111 (app111 v1111 (app111 v1111 (app111 v1111 (app111 v1111 (app111 v1111 (app111 v1111 v0111)))))))\nTy112 : Type\nTy112 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty112 : Ty112\nempty112 = \\ _, empty, _ => empty\n\narr112 : Ty112 -> Ty112 -> Ty112\narr112 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon112 : Type\nCon112 = (Con112 : Type)\n ->(nil : Con112)\n ->(snoc : Con112 -> Ty112 -> Con112)\n -> Con112\n\nnil112 : Con112\nnil112 = \\ con, nil112, snoc => nil112\n\nsnoc112 : Con112 -> Ty112 -> Con112\nsnoc112 = \\ g, a, con, nil112, snoc112 => snoc112 (g con nil112 snoc112) a\n\nVar112 : Con112 -> Ty112 -> Type\nVar112 = \\ g, a =>\n (Var112 : Con112 -> Ty112 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var112 (snoc112 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var112 g a -> Var112 (snoc112 g b) a)\n -> Var112 g a\n\nvz112 : {g : _}-> {a : _} -> Var112 (snoc112 g a) a\nvz112 = \\ var, vz112, vs => vz112 _ _\n\nvs112 : {g : _} -> {B : _} -> {a : _} -> Var112 g a -> Var112 (snoc112 g B) a\nvs112 = \\ x, var, vz112, vs112 => vs112 _ _ _ (x var vz112 vs112)\n\nTm112 : Con112 -> Ty112 -> Type\nTm112 = \\ g, a =>\n (Tm112 : Con112 -> Ty112 -> Type)\n -> (var : (g : _) -> (a : _) -> Var112 g a -> Tm112 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm112 (snoc112 g a) B -> Tm112 g (arr112 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm112 g (arr112 a B) -> Tm112 g a -> Tm112 g B)\n -> Tm112 g a\n\nvar112 : {g : _} -> {a : _} -> Var112 g a -> Tm112 g a\nvar112 = \\ x, tm, var112, lam, app => var112 _ _ x\n\nlam112 : {g : _} -> {a : _} -> {B : _} -> Tm112 (snoc112 g a) B -> Tm112 g (arr112 a B)\nlam112 = \\ t, tm, var112, lam112, app => lam112 _ _ _ (t tm var112 lam112 app)\n\napp112 : {g:_}->{a:_}->{B:_} -> Tm112 g (arr112 a B) -> Tm112 g a -> Tm112 g B\napp112 = \\ t, u, tm, var112, lam112, app112 => app112 _ _ _ (t tm var112 lam112 app112) (u tm var112 lam112 app112)\n\nv0112 : {g:_}->{a:_} -> Tm112 (snoc112 g a) a\nv0112 = var112 vz112\n\nv1112 : {g:_}->{a:_}-> {B:_}-> Tm112 (snoc112 (snoc112 g a) B) a\nv1112 = var112 (vs112 vz112)\n\nv2112 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm112 (snoc112 (snoc112 (snoc112 g a) B) C) a\nv2112 = var112 (vs112 (vs112 vz112))\n\nv3112 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm112 (snoc112 (snoc112 (snoc112 (snoc112 g a) B) C) D) a\nv3112 = var112 (vs112 (vs112 (vs112 vz112)))\n\nv4112 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm112 (snoc112 (snoc112 (snoc112 (snoc112 (snoc112 g a) B) C) D) E) a\nv4112 = var112 (vs112 (vs112 (vs112 (vs112 vz112))))\n\ntest112 : {g:_}-> {a:_} -> Tm112 g (arr112 (arr112 a a) (arr112 a a))\ntest112 = lam112 (lam112 (app112 v1112 (app112 v1112 (app112 v1112 (app112 v1112 (app112 v1112 (app112 v1112 v0112)))))))\nTy113 : Type\nTy113 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty113 : Ty113\nempty113 = \\ _, empty, _ => empty\n\narr113 : Ty113 -> Ty113 -> Ty113\narr113 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon113 : Type\nCon113 = (Con113 : Type)\n ->(nil : Con113)\n ->(snoc : Con113 -> Ty113 -> Con113)\n -> Con113\n\nnil113 : Con113\nnil113 = \\ con, nil113, snoc => nil113\n\nsnoc113 : Con113 -> Ty113 -> Con113\nsnoc113 = \\ g, a, con, nil113, snoc113 => snoc113 (g con nil113 snoc113) a\n\nVar113 : Con113 -> Ty113 -> Type\nVar113 = \\ g, a =>\n (Var113 : Con113 -> Ty113 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var113 (snoc113 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var113 g a -> Var113 (snoc113 g b) a)\n -> Var113 g a\n\nvz113 : {g : _}-> {a : _} -> Var113 (snoc113 g a) a\nvz113 = \\ var, vz113, vs => vz113 _ _\n\nvs113 : {g : _} -> {B : _} -> {a : _} -> Var113 g a -> Var113 (snoc113 g B) a\nvs113 = \\ x, var, vz113, vs113 => vs113 _ _ _ (x var vz113 vs113)\n\nTm113 : Con113 -> Ty113 -> Type\nTm113 = \\ g, a =>\n (Tm113 : Con113 -> Ty113 -> Type)\n -> (var : (g : _) -> (a : _) -> Var113 g a -> Tm113 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm113 (snoc113 g a) B -> Tm113 g (arr113 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm113 g (arr113 a B) -> Tm113 g a -> Tm113 g B)\n -> Tm113 g a\n\nvar113 : {g : _} -> {a : _} -> Var113 g a -> Tm113 g a\nvar113 = \\ x, tm, var113, lam, app => var113 _ _ x\n\nlam113 : {g : _} -> {a : _} -> {B : _} -> Tm113 (snoc113 g a) B -> Tm113 g (arr113 a B)\nlam113 = \\ t, tm, var113, lam113, app => lam113 _ _ _ (t tm var113 lam113 app)\n\napp113 : {g:_}->{a:_}->{B:_} -> Tm113 g (arr113 a B) -> Tm113 g a -> Tm113 g B\napp113 = \\ t, u, tm, var113, lam113, app113 => app113 _ _ _ (t tm var113 lam113 app113) (u tm var113 lam113 app113)\n\nv0113 : {g:_}->{a:_} -> Tm113 (snoc113 g a) a\nv0113 = var113 vz113\n\nv1113 : {g:_}->{a:_}-> {B:_}-> Tm113 (snoc113 (snoc113 g a) B) a\nv1113 = var113 (vs113 vz113)\n\nv2113 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm113 (snoc113 (snoc113 (snoc113 g a) B) C) a\nv2113 = var113 (vs113 (vs113 vz113))\n\nv3113 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm113 (snoc113 (snoc113 (snoc113 (snoc113 g a) B) C) D) a\nv3113 = var113 (vs113 (vs113 (vs113 vz113)))\n\nv4113 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm113 (snoc113 (snoc113 (snoc113 (snoc113 (snoc113 g a) B) C) D) E) a\nv4113 = var113 (vs113 (vs113 (vs113 (vs113 vz113))))\n\ntest113 : {g:_}-> {a:_} -> Tm113 g (arr113 (arr113 a a) (arr113 a a))\ntest113 = lam113 (lam113 (app113 v1113 (app113 v1113 (app113 v1113 (app113 v1113 (app113 v1113 (app113 v1113 v0113)))))))\nTy114 : Type\nTy114 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty114 : Ty114\nempty114 = \\ _, empty, _ => empty\n\narr114 : Ty114 -> Ty114 -> Ty114\narr114 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon114 : Type\nCon114 = (Con114 : Type)\n ->(nil : Con114)\n ->(snoc : Con114 -> Ty114 -> Con114)\n -> Con114\n\nnil114 : Con114\nnil114 = \\ con, nil114, snoc => nil114\n\nsnoc114 : Con114 -> Ty114 -> Con114\nsnoc114 = \\ g, a, con, nil114, snoc114 => snoc114 (g con nil114 snoc114) a\n\nVar114 : Con114 -> Ty114 -> Type\nVar114 = \\ g, a =>\n (Var114 : Con114 -> Ty114 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var114 (snoc114 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var114 g a -> Var114 (snoc114 g b) a)\n -> Var114 g a\n\nvz114 : {g : _}-> {a : _} -> Var114 (snoc114 g a) a\nvz114 = \\ var, vz114, vs => vz114 _ _\n\nvs114 : {g : _} -> {B : _} -> {a : _} -> Var114 g a -> Var114 (snoc114 g B) a\nvs114 = \\ x, var, vz114, vs114 => vs114 _ _ _ (x var vz114 vs114)\n\nTm114 : Con114 -> Ty114 -> Type\nTm114 = \\ g, a =>\n (Tm114 : Con114 -> Ty114 -> Type)\n -> (var : (g : _) -> (a : _) -> Var114 g a -> Tm114 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm114 (snoc114 g a) B -> Tm114 g (arr114 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm114 g (arr114 a B) -> Tm114 g a -> Tm114 g B)\n -> Tm114 g a\n\nvar114 : {g : _} -> {a : _} -> Var114 g a -> Tm114 g a\nvar114 = \\ x, tm, var114, lam, app => var114 _ _ x\n\nlam114 : {g : _} -> {a : _} -> {B : _} -> Tm114 (snoc114 g a) B -> Tm114 g (arr114 a B)\nlam114 = \\ t, tm, var114, lam114, app => lam114 _ _ _ (t tm var114 lam114 app)\n\napp114 : {g:_}->{a:_}->{B:_} -> Tm114 g (arr114 a B) -> Tm114 g a -> Tm114 g B\napp114 = \\ t, u, tm, var114, lam114, app114 => app114 _ _ _ (t tm var114 lam114 app114) (u tm var114 lam114 app114)\n\nv0114 : {g:_}->{a:_} -> Tm114 (snoc114 g a) a\nv0114 = var114 vz114\n\nv1114 : {g:_}->{a:_}-> {B:_}-> Tm114 (snoc114 (snoc114 g a) B) a\nv1114 = var114 (vs114 vz114)\n\nv2114 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm114 (snoc114 (snoc114 (snoc114 g a) B) C) a\nv2114 = var114 (vs114 (vs114 vz114))\n\nv3114 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm114 (snoc114 (snoc114 (snoc114 (snoc114 g a) B) C) D) a\nv3114 = var114 (vs114 (vs114 (vs114 vz114)))\n\nv4114 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm114 (snoc114 (snoc114 (snoc114 (snoc114 (snoc114 g a) B) C) D) E) a\nv4114 = var114 (vs114 (vs114 (vs114 (vs114 vz114))))\n\ntest114 : {g:_}-> {a:_} -> Tm114 g (arr114 (arr114 a a) (arr114 a a))\ntest114 = lam114 (lam114 (app114 v1114 (app114 v1114 (app114 v1114 (app114 v1114 (app114 v1114 (app114 v1114 v0114)))))))\nTy115 : Type\nTy115 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty115 : Ty115\nempty115 = \\ _, empty, _ => empty\n\narr115 : Ty115 -> Ty115 -> Ty115\narr115 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon115 : Type\nCon115 = (Con115 : Type)\n ->(nil : Con115)\n ->(snoc : Con115 -> Ty115 -> Con115)\n -> Con115\n\nnil115 : Con115\nnil115 = \\ con, nil115, snoc => nil115\n\nsnoc115 : Con115 -> Ty115 -> Con115\nsnoc115 = \\ g, a, con, nil115, snoc115 => snoc115 (g con nil115 snoc115) a\n\nVar115 : Con115 -> Ty115 -> Type\nVar115 = \\ g, a =>\n (Var115 : Con115 -> Ty115 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var115 (snoc115 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var115 g a -> Var115 (snoc115 g b) a)\n -> Var115 g a\n\nvz115 : {g : _}-> {a : _} -> Var115 (snoc115 g a) a\nvz115 = \\ var, vz115, vs => vz115 _ _\n\nvs115 : {g : _} -> {B : _} -> {a : _} -> Var115 g a -> Var115 (snoc115 g B) a\nvs115 = \\ x, var, vz115, vs115 => vs115 _ _ _ (x var vz115 vs115)\n\nTm115 : Con115 -> Ty115 -> Type\nTm115 = \\ g, a =>\n (Tm115 : Con115 -> Ty115 -> Type)\n -> (var : (g : _) -> (a : _) -> Var115 g a -> Tm115 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm115 (snoc115 g a) B -> Tm115 g (arr115 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm115 g (arr115 a B) -> Tm115 g a -> Tm115 g B)\n -> Tm115 g a\n\nvar115 : {g : _} -> {a : _} -> Var115 g a -> Tm115 g a\nvar115 = \\ x, tm, var115, lam, app => var115 _ _ x\n\nlam115 : {g : _} -> {a : _} -> {B : _} -> Tm115 (snoc115 g a) B -> Tm115 g (arr115 a B)\nlam115 = \\ t, tm, var115, lam115, app => lam115 _ _ _ (t tm var115 lam115 app)\n\napp115 : {g:_}->{a:_}->{B:_} -> Tm115 g (arr115 a B) -> Tm115 g a -> Tm115 g B\napp115 = \\ t, u, tm, var115, lam115, app115 => app115 _ _ _ (t tm var115 lam115 app115) (u tm var115 lam115 app115)\n\nv0115 : {g:_}->{a:_} -> Tm115 (snoc115 g a) a\nv0115 = var115 vz115\n\nv1115 : {g:_}->{a:_}-> {B:_}-> Tm115 (snoc115 (snoc115 g a) B) a\nv1115 = var115 (vs115 vz115)\n\nv2115 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm115 (snoc115 (snoc115 (snoc115 g a) B) C) a\nv2115 = var115 (vs115 (vs115 vz115))\n\nv3115 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm115 (snoc115 (snoc115 (snoc115 (snoc115 g a) B) C) D) a\nv3115 = var115 (vs115 (vs115 (vs115 vz115)))\n\nv4115 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm115 (snoc115 (snoc115 (snoc115 (snoc115 (snoc115 g a) B) C) D) E) a\nv4115 = var115 (vs115 (vs115 (vs115 (vs115 vz115))))\n\ntest115 : {g:_}-> {a:_} -> Tm115 g (arr115 (arr115 a a) (arr115 a a))\ntest115 = lam115 (lam115 (app115 v1115 (app115 v1115 (app115 v1115 (app115 v1115 (app115 v1115 (app115 v1115 v0115)))))))\nTy116 : Type\nTy116 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty116 : Ty116\nempty116 = \\ _, empty, _ => empty\n\narr116 : Ty116 -> Ty116 -> Ty116\narr116 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon116 : Type\nCon116 = (Con116 : Type)\n ->(nil : Con116)\n ->(snoc : Con116 -> Ty116 -> Con116)\n -> Con116\n\nnil116 : Con116\nnil116 = \\ con, nil116, snoc => nil116\n\nsnoc116 : Con116 -> Ty116 -> Con116\nsnoc116 = \\ g, a, con, nil116, snoc116 => snoc116 (g con nil116 snoc116) a\n\nVar116 : Con116 -> Ty116 -> Type\nVar116 = \\ g, a =>\n (Var116 : Con116 -> Ty116 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var116 (snoc116 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var116 g a -> Var116 (snoc116 g b) a)\n -> Var116 g a\n\nvz116 : {g : _}-> {a : _} -> Var116 (snoc116 g a) a\nvz116 = \\ var, vz116, vs => vz116 _ _\n\nvs116 : {g : _} -> {B : _} -> {a : _} -> Var116 g a -> Var116 (snoc116 g B) a\nvs116 = \\ x, var, vz116, vs116 => vs116 _ _ _ (x var vz116 vs116)\n\nTm116 : Con116 -> Ty116 -> Type\nTm116 = \\ g, a =>\n (Tm116 : Con116 -> Ty116 -> Type)\n -> (var : (g : _) -> (a : _) -> Var116 g a -> Tm116 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm116 (snoc116 g a) B -> Tm116 g (arr116 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm116 g (arr116 a B) -> Tm116 g a -> Tm116 g B)\n -> Tm116 g a\n\nvar116 : {g : _} -> {a : _} -> Var116 g a -> Tm116 g a\nvar116 = \\ x, tm, var116, lam, app => var116 _ _ x\n\nlam116 : {g : _} -> {a : _} -> {B : _} -> Tm116 (snoc116 g a) B -> Tm116 g (arr116 a B)\nlam116 = \\ t, tm, var116, lam116, app => lam116 _ _ _ (t tm var116 lam116 app)\n\napp116 : {g:_}->{a:_}->{B:_} -> Tm116 g (arr116 a B) -> Tm116 g a -> Tm116 g B\napp116 = \\ t, u, tm, var116, lam116, app116 => app116 _ _ _ (t tm var116 lam116 app116) (u tm var116 lam116 app116)\n\nv0116 : {g:_}->{a:_} -> Tm116 (snoc116 g a) a\nv0116 = var116 vz116\n\nv1116 : {g:_}->{a:_}-> {B:_}-> Tm116 (snoc116 (snoc116 g a) B) a\nv1116 = var116 (vs116 vz116)\n\nv2116 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm116 (snoc116 (snoc116 (snoc116 g a) B) C) a\nv2116 = var116 (vs116 (vs116 vz116))\n\nv3116 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm116 (snoc116 (snoc116 (snoc116 (snoc116 g a) B) C) D) a\nv3116 = var116 (vs116 (vs116 (vs116 vz116)))\n\nv4116 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm116 (snoc116 (snoc116 (snoc116 (snoc116 (snoc116 g a) B) C) D) E) a\nv4116 = var116 (vs116 (vs116 (vs116 (vs116 vz116))))\n\ntest116 : {g:_}-> {a:_} -> Tm116 g (arr116 (arr116 a a) (arr116 a a))\ntest116 = lam116 (lam116 (app116 v1116 (app116 v1116 (app116 v1116 (app116 v1116 (app116 v1116 (app116 v1116 v0116)))))))\nTy117 : Type\nTy117 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty117 : Ty117\nempty117 = \\ _, empty, _ => empty\n\narr117 : Ty117 -> Ty117 -> Ty117\narr117 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon117 : Type\nCon117 = (Con117 : Type)\n ->(nil : Con117)\n ->(snoc : Con117 -> Ty117 -> Con117)\n -> Con117\n\nnil117 : Con117\nnil117 = \\ con, nil117, snoc => nil117\n\nsnoc117 : Con117 -> Ty117 -> Con117\nsnoc117 = \\ g, a, con, nil117, snoc117 => snoc117 (g con nil117 snoc117) a\n\nVar117 : Con117 -> Ty117 -> Type\nVar117 = \\ g, a =>\n (Var117 : Con117 -> Ty117 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var117 (snoc117 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var117 g a -> Var117 (snoc117 g b) a)\n -> Var117 g a\n\nvz117 : {g : _}-> {a : _} -> Var117 (snoc117 g a) a\nvz117 = \\ var, vz117, vs => vz117 _ _\n\nvs117 : {g : _} -> {B : _} -> {a : _} -> Var117 g a -> Var117 (snoc117 g B) a\nvs117 = \\ x, var, vz117, vs117 => vs117 _ _ _ (x var vz117 vs117)\n\nTm117 : Con117 -> Ty117 -> Type\nTm117 = \\ g, a =>\n (Tm117 : Con117 -> Ty117 -> Type)\n -> (var : (g : _) -> (a : _) -> Var117 g a -> Tm117 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm117 (snoc117 g a) B -> Tm117 g (arr117 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm117 g (arr117 a B) -> Tm117 g a -> Tm117 g B)\n -> Tm117 g a\n\nvar117 : {g : _} -> {a : _} -> Var117 g a -> Tm117 g a\nvar117 = \\ x, tm, var117, lam, app => var117 _ _ x\n\nlam117 : {g : _} -> {a : _} -> {B : _} -> Tm117 (snoc117 g a) B -> Tm117 g (arr117 a B)\nlam117 = \\ t, tm, var117, lam117, app => lam117 _ _ _ (t tm var117 lam117 app)\n\napp117 : {g:_}->{a:_}->{B:_} -> Tm117 g (arr117 a B) -> Tm117 g a -> Tm117 g B\napp117 = \\ t, u, tm, var117, lam117, app117 => app117 _ _ _ (t tm var117 lam117 app117) (u tm var117 lam117 app117)\n\nv0117 : {g:_}->{a:_} -> Tm117 (snoc117 g a) a\nv0117 = var117 vz117\n\nv1117 : {g:_}->{a:_}-> {B:_}-> Tm117 (snoc117 (snoc117 g a) B) a\nv1117 = var117 (vs117 vz117)\n\nv2117 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm117 (snoc117 (snoc117 (snoc117 g a) B) C) a\nv2117 = var117 (vs117 (vs117 vz117))\n\nv3117 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm117 (snoc117 (snoc117 (snoc117 (snoc117 g a) B) C) D) a\nv3117 = var117 (vs117 (vs117 (vs117 vz117)))\n\nv4117 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm117 (snoc117 (snoc117 (snoc117 (snoc117 (snoc117 g a) B) C) D) E) a\nv4117 = var117 (vs117 (vs117 (vs117 (vs117 vz117))))\n\ntest117 : {g:_}-> {a:_} -> Tm117 g (arr117 (arr117 a a) (arr117 a a))\ntest117 = lam117 (lam117 (app117 v1117 (app117 v1117 (app117 v1117 (app117 v1117 (app117 v1117 (app117 v1117 v0117)))))))\nTy118 : Type\nTy118 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty118 : Ty118\nempty118 = \\ _, empty, _ => empty\n\narr118 : Ty118 -> Ty118 -> Ty118\narr118 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon118 : Type\nCon118 = (Con118 : Type)\n ->(nil : Con118)\n ->(snoc : Con118 -> Ty118 -> Con118)\n -> Con118\n\nnil118 : Con118\nnil118 = \\ con, nil118, snoc => nil118\n\nsnoc118 : Con118 -> Ty118 -> Con118\nsnoc118 = \\ g, a, con, nil118, snoc118 => snoc118 (g con nil118 snoc118) a\n\nVar118 : Con118 -> Ty118 -> Type\nVar118 = \\ g, a =>\n (Var118 : Con118 -> Ty118 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var118 (snoc118 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var118 g a -> Var118 (snoc118 g b) a)\n -> Var118 g a\n\nvz118 : {g : _}-> {a : _} -> Var118 (snoc118 g a) a\nvz118 = \\ var, vz118, vs => vz118 _ _\n\nvs118 : {g : _} -> {B : _} -> {a : _} -> Var118 g a -> Var118 (snoc118 g B) a\nvs118 = \\ x, var, vz118, vs118 => vs118 _ _ _ (x var vz118 vs118)\n\nTm118 : Con118 -> Ty118 -> Type\nTm118 = \\ g, a =>\n (Tm118 : Con118 -> Ty118 -> Type)\n -> (var : (g : _) -> (a : _) -> Var118 g a -> Tm118 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm118 (snoc118 g a) B -> Tm118 g (arr118 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm118 g (arr118 a B) -> Tm118 g a -> Tm118 g B)\n -> Tm118 g a\n\nvar118 : {g : _} -> {a : _} -> Var118 g a -> Tm118 g a\nvar118 = \\ x, tm, var118, lam, app => var118 _ _ x\n\nlam118 : {g : _} -> {a : _} -> {B : _} -> Tm118 (snoc118 g a) B -> Tm118 g (arr118 a B)\nlam118 = \\ t, tm, var118, lam118, app => lam118 _ _ _ (t tm var118 lam118 app)\n\napp118 : {g:_}->{a:_}->{B:_} -> Tm118 g (arr118 a B) -> Tm118 g a -> Tm118 g B\napp118 = \\ t, u, tm, var118, lam118, app118 => app118 _ _ _ (t tm var118 lam118 app118) (u tm var118 lam118 app118)\n\nv0118 : {g:_}->{a:_} -> Tm118 (snoc118 g a) a\nv0118 = var118 vz118\n\nv1118 : {g:_}->{a:_}-> {B:_}-> Tm118 (snoc118 (snoc118 g a) B) a\nv1118 = var118 (vs118 vz118)\n\nv2118 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm118 (snoc118 (snoc118 (snoc118 g a) B) C) a\nv2118 = var118 (vs118 (vs118 vz118))\n\nv3118 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm118 (snoc118 (snoc118 (snoc118 (snoc118 g a) B) C) D) a\nv3118 = var118 (vs118 (vs118 (vs118 vz118)))\n\nv4118 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm118 (snoc118 (snoc118 (snoc118 (snoc118 (snoc118 g a) B) C) D) E) a\nv4118 = var118 (vs118 (vs118 (vs118 (vs118 vz118))))\n\ntest118 : {g:_}-> {a:_} -> Tm118 g (arr118 (arr118 a a) (arr118 a a))\ntest118 = lam118 (lam118 (app118 v1118 (app118 v1118 (app118 v1118 (app118 v1118 (app118 v1118 (app118 v1118 v0118)))))))\nTy119 : Type\nTy119 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty119 : Ty119\nempty119 = \\ _, empty, _ => empty\n\narr119 : Ty119 -> Ty119 -> Ty119\narr119 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon119 : Type\nCon119 = (Con119 : Type)\n ->(nil : Con119)\n ->(snoc : Con119 -> Ty119 -> Con119)\n -> Con119\n\nnil119 : Con119\nnil119 = \\ con, nil119, snoc => nil119\n\nsnoc119 : Con119 -> Ty119 -> Con119\nsnoc119 = \\ g, a, con, nil119, snoc119 => snoc119 (g con nil119 snoc119) a\n\nVar119 : Con119 -> Ty119 -> Type\nVar119 = \\ g, a =>\n (Var119 : Con119 -> Ty119 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var119 (snoc119 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var119 g a -> Var119 (snoc119 g b) a)\n -> Var119 g a\n\nvz119 : {g : _}-> {a : _} -> Var119 (snoc119 g a) a\nvz119 = \\ var, vz119, vs => vz119 _ _\n\nvs119 : {g : _} -> {B : _} -> {a : _} -> Var119 g a -> Var119 (snoc119 g B) a\nvs119 = \\ x, var, vz119, vs119 => vs119 _ _ _ (x var vz119 vs119)\n\nTm119 : Con119 -> Ty119 -> Type\nTm119 = \\ g, a =>\n (Tm119 : Con119 -> Ty119 -> Type)\n -> (var : (g : _) -> (a : _) -> Var119 g a -> Tm119 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm119 (snoc119 g a) B -> Tm119 g (arr119 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm119 g (arr119 a B) -> Tm119 g a -> Tm119 g B)\n -> Tm119 g a\n\nvar119 : {g : _} -> {a : _} -> Var119 g a -> Tm119 g a\nvar119 = \\ x, tm, var119, lam, app => var119 _ _ x\n\nlam119 : {g : _} -> {a : _} -> {B : _} -> Tm119 (snoc119 g a) B -> Tm119 g (arr119 a B)\nlam119 = \\ t, tm, var119, lam119, app => lam119 _ _ _ (t tm var119 lam119 app)\n\napp119 : {g:_}->{a:_}->{B:_} -> Tm119 g (arr119 a B) -> Tm119 g a -> Tm119 g B\napp119 = \\ t, u, tm, var119, lam119, app119 => app119 _ _ _ (t tm var119 lam119 app119) (u tm var119 lam119 app119)\n\nv0119 : {g:_}->{a:_} -> Tm119 (snoc119 g a) a\nv0119 = var119 vz119\n\nv1119 : {g:_}->{a:_}-> {B:_}-> Tm119 (snoc119 (snoc119 g a) B) a\nv1119 = var119 (vs119 vz119)\n\nv2119 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm119 (snoc119 (snoc119 (snoc119 g a) B) C) a\nv2119 = var119 (vs119 (vs119 vz119))\n\nv3119 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm119 (snoc119 (snoc119 (snoc119 (snoc119 g a) B) C) D) a\nv3119 = var119 (vs119 (vs119 (vs119 vz119)))\n\nv4119 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm119 (snoc119 (snoc119 (snoc119 (snoc119 (snoc119 g a) B) C) D) E) a\nv4119 = var119 (vs119 (vs119 (vs119 (vs119 vz119))))\n\ntest119 : {g:_}-> {a:_} -> Tm119 g (arr119 (arr119 a a) (arr119 a a))\ntest119 = lam119 (lam119 (app119 v1119 (app119 v1119 (app119 v1119 (app119 v1119 (app119 v1119 (app119 v1119 v0119)))))))\nTy120 : Type\nTy120 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty120 : Ty120\nempty120 = \\ _, empty, _ => empty\n\narr120 : Ty120 -> Ty120 -> Ty120\narr120 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon120 : Type\nCon120 = (Con120 : Type)\n ->(nil : Con120)\n ->(snoc : Con120 -> Ty120 -> Con120)\n -> Con120\n\nnil120 : Con120\nnil120 = \\ con, nil120, snoc => nil120\n\nsnoc120 : Con120 -> Ty120 -> Con120\nsnoc120 = \\ g, a, con, nil120, snoc120 => snoc120 (g con nil120 snoc120) a\n\nVar120 : Con120 -> Ty120 -> Type\nVar120 = \\ g, a =>\n (Var120 : Con120 -> Ty120 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var120 (snoc120 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var120 g a -> Var120 (snoc120 g b) a)\n -> Var120 g a\n\nvz120 : {g : _}-> {a : _} -> Var120 (snoc120 g a) a\nvz120 = \\ var, vz120, vs => vz120 _ _\n\nvs120 : {g : _} -> {B : _} -> {a : _} -> Var120 g a -> Var120 (snoc120 g B) a\nvs120 = \\ x, var, vz120, vs120 => vs120 _ _ _ (x var vz120 vs120)\n\nTm120 : Con120 -> Ty120 -> Type\nTm120 = \\ g, a =>\n (Tm120 : Con120 -> Ty120 -> Type)\n -> (var : (g : _) -> (a : _) -> Var120 g a -> Tm120 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm120 (snoc120 g a) B -> Tm120 g (arr120 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm120 g (arr120 a B) -> Tm120 g a -> Tm120 g B)\n -> Tm120 g a\n\nvar120 : {g : _} -> {a : _} -> Var120 g a -> Tm120 g a\nvar120 = \\ x, tm, var120, lam, app => var120 _ _ x\n\nlam120 : {g : _} -> {a : _} -> {B : _} -> Tm120 (snoc120 g a) B -> Tm120 g (arr120 a B)\nlam120 = \\ t, tm, var120, lam120, app => lam120 _ _ _ (t tm var120 lam120 app)\n\napp120 : {g:_}->{a:_}->{B:_} -> Tm120 g (arr120 a B) -> Tm120 g a -> Tm120 g B\napp120 = \\ t, u, tm, var120, lam120, app120 => app120 _ _ _ (t tm var120 lam120 app120) (u tm var120 lam120 app120)\n\nv0120 : {g:_}->{a:_} -> Tm120 (snoc120 g a) a\nv0120 = var120 vz120\n\nv1120 : {g:_}->{a:_}-> {B:_}-> Tm120 (snoc120 (snoc120 g a) B) a\nv1120 = var120 (vs120 vz120)\n\nv2120 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm120 (snoc120 (snoc120 (snoc120 g a) B) C) a\nv2120 = var120 (vs120 (vs120 vz120))\n\nv3120 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm120 (snoc120 (snoc120 (snoc120 (snoc120 g a) B) C) D) a\nv3120 = var120 (vs120 (vs120 (vs120 vz120)))\n\nv4120 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm120 (snoc120 (snoc120 (snoc120 (snoc120 (snoc120 g a) B) C) D) E) a\nv4120 = var120 (vs120 (vs120 (vs120 (vs120 vz120))))\n\ntest120 : {g:_}-> {a:_} -> Tm120 g (arr120 (arr120 a a) (arr120 a a))\ntest120 = lam120 (lam120 (app120 v1120 (app120 v1120 (app120 v1120 (app120 v1120 (app120 v1120 (app120 v1120 v0120)))))))\nTy121 : Type\nTy121 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty121 : Ty121\nempty121 = \\ _, empty, _ => empty\n\narr121 : Ty121 -> Ty121 -> Ty121\narr121 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon121 : Type\nCon121 = (Con121 : Type)\n ->(nil : Con121)\n ->(snoc : Con121 -> Ty121 -> Con121)\n -> Con121\n\nnil121 : Con121\nnil121 = \\ con, nil121, snoc => nil121\n\nsnoc121 : Con121 -> Ty121 -> Con121\nsnoc121 = \\ g, a, con, nil121, snoc121 => snoc121 (g con nil121 snoc121) a\n\nVar121 : Con121 -> Ty121 -> Type\nVar121 = \\ g, a =>\n (Var121 : Con121 -> Ty121 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var121 (snoc121 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var121 g a -> Var121 (snoc121 g b) a)\n -> Var121 g a\n\nvz121 : {g : _}-> {a : _} -> Var121 (snoc121 g a) a\nvz121 = \\ var, vz121, vs => vz121 _ _\n\nvs121 : {g : _} -> {B : _} -> {a : _} -> Var121 g a -> Var121 (snoc121 g B) a\nvs121 = \\ x, var, vz121, vs121 => vs121 _ _ _ (x var vz121 vs121)\n\nTm121 : Con121 -> Ty121 -> Type\nTm121 = \\ g, a =>\n (Tm121 : Con121 -> Ty121 -> Type)\n -> (var : (g : _) -> (a : _) -> Var121 g a -> Tm121 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm121 (snoc121 g a) B -> Tm121 g (arr121 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm121 g (arr121 a B) -> Tm121 g a -> Tm121 g B)\n -> Tm121 g a\n\nvar121 : {g : _} -> {a : _} -> Var121 g a -> Tm121 g a\nvar121 = \\ x, tm, var121, lam, app => var121 _ _ x\n\nlam121 : {g : _} -> {a : _} -> {B : _} -> Tm121 (snoc121 g a) B -> Tm121 g (arr121 a B)\nlam121 = \\ t, tm, var121, lam121, app => lam121 _ _ _ (t tm var121 lam121 app)\n\napp121 : {g:_}->{a:_}->{B:_} -> Tm121 g (arr121 a B) -> Tm121 g a -> Tm121 g B\napp121 = \\ t, u, tm, var121, lam121, app121 => app121 _ _ _ (t tm var121 lam121 app121) (u tm var121 lam121 app121)\n\nv0121 : {g:_}->{a:_} -> Tm121 (snoc121 g a) a\nv0121 = var121 vz121\n\nv1121 : {g:_}->{a:_}-> {B:_}-> Tm121 (snoc121 (snoc121 g a) B) a\nv1121 = var121 (vs121 vz121)\n\nv2121 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm121 (snoc121 (snoc121 (snoc121 g a) B) C) a\nv2121 = var121 (vs121 (vs121 vz121))\n\nv3121 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm121 (snoc121 (snoc121 (snoc121 (snoc121 g a) B) C) D) a\nv3121 = var121 (vs121 (vs121 (vs121 vz121)))\n\nv4121 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm121 (snoc121 (snoc121 (snoc121 (snoc121 (snoc121 g a) B) C) D) E) a\nv4121 = var121 (vs121 (vs121 (vs121 (vs121 vz121))))\n\ntest121 : {g:_}-> {a:_} -> Tm121 g (arr121 (arr121 a a) (arr121 a a))\ntest121 = lam121 (lam121 (app121 v1121 (app121 v1121 (app121 v1121 (app121 v1121 (app121 v1121 (app121 v1121 v0121)))))))\nTy122 : Type\nTy122 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty122 : Ty122\nempty122 = \\ _, empty, _ => empty\n\narr122 : Ty122 -> Ty122 -> Ty122\narr122 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon122 : Type\nCon122 = (Con122 : Type)\n ->(nil : Con122)\n ->(snoc : Con122 -> Ty122 -> Con122)\n -> Con122\n\nnil122 : Con122\nnil122 = \\ con, nil122, snoc => nil122\n\nsnoc122 : Con122 -> Ty122 -> Con122\nsnoc122 = \\ g, a, con, nil122, snoc122 => snoc122 (g con nil122 snoc122) a\n\nVar122 : Con122 -> Ty122 -> Type\nVar122 = \\ g, a =>\n (Var122 : Con122 -> Ty122 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var122 (snoc122 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var122 g a -> Var122 (snoc122 g b) a)\n -> Var122 g a\n\nvz122 : {g : _}-> {a : _} -> Var122 (snoc122 g a) a\nvz122 = \\ var, vz122, vs => vz122 _ _\n\nvs122 : {g : _} -> {B : _} -> {a : _} -> Var122 g a -> Var122 (snoc122 g B) a\nvs122 = \\ x, var, vz122, vs122 => vs122 _ _ _ (x var vz122 vs122)\n\nTm122 : Con122 -> Ty122 -> Type\nTm122 = \\ g, a =>\n (Tm122 : Con122 -> Ty122 -> Type)\n -> (var : (g : _) -> (a : _) -> Var122 g a -> Tm122 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm122 (snoc122 g a) B -> Tm122 g (arr122 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm122 g (arr122 a B) -> Tm122 g a -> Tm122 g B)\n -> Tm122 g a\n\nvar122 : {g : _} -> {a : _} -> Var122 g a -> Tm122 g a\nvar122 = \\ x, tm, var122, lam, app => var122 _ _ x\n\nlam122 : {g : _} -> {a : _} -> {B : _} -> Tm122 (snoc122 g a) B -> Tm122 g (arr122 a B)\nlam122 = \\ t, tm, var122, lam122, app => lam122 _ _ _ (t tm var122 lam122 app)\n\napp122 : {g:_}->{a:_}->{B:_} -> Tm122 g (arr122 a B) -> Tm122 g a -> Tm122 g B\napp122 = \\ t, u, tm, var122, lam122, app122 => app122 _ _ _ (t tm var122 lam122 app122) (u tm var122 lam122 app122)\n\nv0122 : {g:_}->{a:_} -> Tm122 (snoc122 g a) a\nv0122 = var122 vz122\n\nv1122 : {g:_}->{a:_}-> {B:_}-> Tm122 (snoc122 (snoc122 g a) B) a\nv1122 = var122 (vs122 vz122)\n\nv2122 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm122 (snoc122 (snoc122 (snoc122 g a) B) C) a\nv2122 = var122 (vs122 (vs122 vz122))\n\nv3122 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm122 (snoc122 (snoc122 (snoc122 (snoc122 g a) B) C) D) a\nv3122 = var122 (vs122 (vs122 (vs122 vz122)))\n\nv4122 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm122 (snoc122 (snoc122 (snoc122 (snoc122 (snoc122 g a) B) C) D) E) a\nv4122 = var122 (vs122 (vs122 (vs122 (vs122 vz122))))\n\ntest122 : {g:_}-> {a:_} -> Tm122 g (arr122 (arr122 a a) (arr122 a a))\ntest122 = lam122 (lam122 (app122 v1122 (app122 v1122 (app122 v1122 (app122 v1122 (app122 v1122 (app122 v1122 v0122)))))))\nTy123 : Type\nTy123 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty123 : Ty123\nempty123 = \\ _, empty, _ => empty\n\narr123 : Ty123 -> Ty123 -> Ty123\narr123 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon123 : Type\nCon123 = (Con123 : Type)\n ->(nil : Con123)\n ->(snoc : Con123 -> Ty123 -> Con123)\n -> Con123\n\nnil123 : Con123\nnil123 = \\ con, nil123, snoc => nil123\n\nsnoc123 : Con123 -> Ty123 -> Con123\nsnoc123 = \\ g, a, con, nil123, snoc123 => snoc123 (g con nil123 snoc123) a\n\nVar123 : Con123 -> Ty123 -> Type\nVar123 = \\ g, a =>\n (Var123 : Con123 -> Ty123 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var123 (snoc123 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var123 g a -> Var123 (snoc123 g b) a)\n -> Var123 g a\n\nvz123 : {g : _}-> {a : _} -> Var123 (snoc123 g a) a\nvz123 = \\ var, vz123, vs => vz123 _ _\n\nvs123 : {g : _} -> {B : _} -> {a : _} -> Var123 g a -> Var123 (snoc123 g B) a\nvs123 = \\ x, var, vz123, vs123 => vs123 _ _ _ (x var vz123 vs123)\n\nTm123 : Con123 -> Ty123 -> Type\nTm123 = \\ g, a =>\n (Tm123 : Con123 -> Ty123 -> Type)\n -> (var : (g : _) -> (a : _) -> Var123 g a -> Tm123 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm123 (snoc123 g a) B -> Tm123 g (arr123 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm123 g (arr123 a B) -> Tm123 g a -> Tm123 g B)\n -> Tm123 g a\n\nvar123 : {g : _} -> {a : _} -> Var123 g a -> Tm123 g a\nvar123 = \\ x, tm, var123, lam, app => var123 _ _ x\n\nlam123 : {g : _} -> {a : _} -> {B : _} -> Tm123 (snoc123 g a) B -> Tm123 g (arr123 a B)\nlam123 = \\ t, tm, var123, lam123, app => lam123 _ _ _ (t tm var123 lam123 app)\n\napp123 : {g:_}->{a:_}->{B:_} -> Tm123 g (arr123 a B) -> Tm123 g a -> Tm123 g B\napp123 = \\ t, u, tm, var123, lam123, app123 => app123 _ _ _ (t tm var123 lam123 app123) (u tm var123 lam123 app123)\n\nv0123 : {g:_}->{a:_} -> Tm123 (snoc123 g a) a\nv0123 = var123 vz123\n\nv1123 : {g:_}->{a:_}-> {B:_}-> Tm123 (snoc123 (snoc123 g a) B) a\nv1123 = var123 (vs123 vz123)\n\nv2123 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm123 (snoc123 (snoc123 (snoc123 g a) B) C) a\nv2123 = var123 (vs123 (vs123 vz123))\n\nv3123 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm123 (snoc123 (snoc123 (snoc123 (snoc123 g a) B) C) D) a\nv3123 = var123 (vs123 (vs123 (vs123 vz123)))\n\nv4123 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm123 (snoc123 (snoc123 (snoc123 (snoc123 (snoc123 g a) B) C) D) E) a\nv4123 = var123 (vs123 (vs123 (vs123 (vs123 vz123))))\n\ntest123 : {g:_}-> {a:_} -> Tm123 g (arr123 (arr123 a a) (arr123 a a))\ntest123 = lam123 (lam123 (app123 v1123 (app123 v1123 (app123 v1123 (app123 v1123 (app123 v1123 (app123 v1123 v0123)))))))\nTy124 : Type\nTy124 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty124 : Ty124\nempty124 = \\ _, empty, _ => empty\n\narr124 : Ty124 -> Ty124 -> Ty124\narr124 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon124 : Type\nCon124 = (Con124 : Type)\n ->(nil : Con124)\n ->(snoc : Con124 -> Ty124 -> Con124)\n -> Con124\n\nnil124 : Con124\nnil124 = \\ con, nil124, snoc => nil124\n\nsnoc124 : Con124 -> Ty124 -> Con124\nsnoc124 = \\ g, a, con, nil124, snoc124 => snoc124 (g con nil124 snoc124) a\n\nVar124 : Con124 -> Ty124 -> Type\nVar124 = \\ g, a =>\n (Var124 : Con124 -> Ty124 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var124 (snoc124 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var124 g a -> Var124 (snoc124 g b) a)\n -> Var124 g a\n\nvz124 : {g : _}-> {a : _} -> Var124 (snoc124 g a) a\nvz124 = \\ var, vz124, vs => vz124 _ _\n\nvs124 : {g : _} -> {B : _} -> {a : _} -> Var124 g a -> Var124 (snoc124 g B) a\nvs124 = \\ x, var, vz124, vs124 => vs124 _ _ _ (x var vz124 vs124)\n\nTm124 : Con124 -> Ty124 -> Type\nTm124 = \\ g, a =>\n (Tm124 : Con124 -> Ty124 -> Type)\n -> (var : (g : _) -> (a : _) -> Var124 g a -> Tm124 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm124 (snoc124 g a) B -> Tm124 g (arr124 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm124 g (arr124 a B) -> Tm124 g a -> Tm124 g B)\n -> Tm124 g a\n\nvar124 : {g : _} -> {a : _} -> Var124 g a -> Tm124 g a\nvar124 = \\ x, tm, var124, lam, app => var124 _ _ x\n\nlam124 : {g : _} -> {a : _} -> {B : _} -> Tm124 (snoc124 g a) B -> Tm124 g (arr124 a B)\nlam124 = \\ t, tm, var124, lam124, app => lam124 _ _ _ (t tm var124 lam124 app)\n\napp124 : {g:_}->{a:_}->{B:_} -> Tm124 g (arr124 a B) -> Tm124 g a -> Tm124 g B\napp124 = \\ t, u, tm, var124, lam124, app124 => app124 _ _ _ (t tm var124 lam124 app124) (u tm var124 lam124 app124)\n\nv0124 : {g:_}->{a:_} -> Tm124 (snoc124 g a) a\nv0124 = var124 vz124\n\nv1124 : {g:_}->{a:_}-> {B:_}-> Tm124 (snoc124 (snoc124 g a) B) a\nv1124 = var124 (vs124 vz124)\n\nv2124 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm124 (snoc124 (snoc124 (snoc124 g a) B) C) a\nv2124 = var124 (vs124 (vs124 vz124))\n\nv3124 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm124 (snoc124 (snoc124 (snoc124 (snoc124 g a) B) C) D) a\nv3124 = var124 (vs124 (vs124 (vs124 vz124)))\n\nv4124 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm124 (snoc124 (snoc124 (snoc124 (snoc124 (snoc124 g a) B) C) D) E) a\nv4124 = var124 (vs124 (vs124 (vs124 (vs124 vz124))))\n\ntest124 : {g:_}-> {a:_} -> Tm124 g (arr124 (arr124 a a) (arr124 a a))\ntest124 = lam124 (lam124 (app124 v1124 (app124 v1124 (app124 v1124 (app124 v1124 (app124 v1124 (app124 v1124 v0124)))))))\nTy125 : Type\nTy125 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty125 : Ty125\nempty125 = \\ _, empty, _ => empty\n\narr125 : Ty125 -> Ty125 -> Ty125\narr125 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon125 : Type\nCon125 = (Con125 : Type)\n ->(nil : Con125)\n ->(snoc : Con125 -> Ty125 -> Con125)\n -> Con125\n\nnil125 : Con125\nnil125 = \\ con, nil125, snoc => nil125\n\nsnoc125 : Con125 -> Ty125 -> Con125\nsnoc125 = \\ g, a, con, nil125, snoc125 => snoc125 (g con nil125 snoc125) a\n\nVar125 : Con125 -> Ty125 -> Type\nVar125 = \\ g, a =>\n (Var125 : Con125 -> Ty125 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var125 (snoc125 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var125 g a -> Var125 (snoc125 g b) a)\n -> Var125 g a\n\nvz125 : {g : _}-> {a : _} -> Var125 (snoc125 g a) a\nvz125 = \\ var, vz125, vs => vz125 _ _\n\nvs125 : {g : _} -> {B : _} -> {a : _} -> Var125 g a -> Var125 (snoc125 g B) a\nvs125 = \\ x, var, vz125, vs125 => vs125 _ _ _ (x var vz125 vs125)\n\nTm125 : Con125 -> Ty125 -> Type\nTm125 = \\ g, a =>\n (Tm125 : Con125 -> Ty125 -> Type)\n -> (var : (g : _) -> (a : _) -> Var125 g a -> Tm125 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm125 (snoc125 g a) B -> Tm125 g (arr125 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm125 g (arr125 a B) -> Tm125 g a -> Tm125 g B)\n -> Tm125 g a\n\nvar125 : {g : _} -> {a : _} -> Var125 g a -> Tm125 g a\nvar125 = \\ x, tm, var125, lam, app => var125 _ _ x\n\nlam125 : {g : _} -> {a : _} -> {B : _} -> Tm125 (snoc125 g a) B -> Tm125 g (arr125 a B)\nlam125 = \\ t, tm, var125, lam125, app => lam125 _ _ _ (t tm var125 lam125 app)\n\napp125 : {g:_}->{a:_}->{B:_} -> Tm125 g (arr125 a B) -> Tm125 g a -> Tm125 g B\napp125 = \\ t, u, tm, var125, lam125, app125 => app125 _ _ _ (t tm var125 lam125 app125) (u tm var125 lam125 app125)\n\nv0125 : {g:_}->{a:_} -> Tm125 (snoc125 g a) a\nv0125 = var125 vz125\n\nv1125 : {g:_}->{a:_}-> {B:_}-> Tm125 (snoc125 (snoc125 g a) B) a\nv1125 = var125 (vs125 vz125)\n\nv2125 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm125 (snoc125 (snoc125 (snoc125 g a) B) C) a\nv2125 = var125 (vs125 (vs125 vz125))\n\nv3125 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm125 (snoc125 (snoc125 (snoc125 (snoc125 g a) B) C) D) a\nv3125 = var125 (vs125 (vs125 (vs125 vz125)))\n\nv4125 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm125 (snoc125 (snoc125 (snoc125 (snoc125 (snoc125 g a) B) C) D) E) a\nv4125 = var125 (vs125 (vs125 (vs125 (vs125 vz125))))\n\ntest125 : {g:_}-> {a:_} -> Tm125 g (arr125 (arr125 a a) (arr125 a a))\ntest125 = lam125 (lam125 (app125 v1125 (app125 v1125 (app125 v1125 (app125 v1125 (app125 v1125 (app125 v1125 v0125)))))))\nTy126 : Type\nTy126 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty126 : Ty126\nempty126 = \\ _, empty, _ => empty\n\narr126 : Ty126 -> Ty126 -> Ty126\narr126 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon126 : Type\nCon126 = (Con126 : Type)\n ->(nil : Con126)\n ->(snoc : Con126 -> Ty126 -> Con126)\n -> Con126\n\nnil126 : Con126\nnil126 = \\ con, nil126, snoc => nil126\n\nsnoc126 : Con126 -> Ty126 -> Con126\nsnoc126 = \\ g, a, con, nil126, snoc126 => snoc126 (g con nil126 snoc126) a\n\nVar126 : Con126 -> Ty126 -> Type\nVar126 = \\ g, a =>\n (Var126 : Con126 -> Ty126 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var126 (snoc126 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var126 g a -> Var126 (snoc126 g b) a)\n -> Var126 g a\n\nvz126 : {g : _}-> {a : _} -> Var126 (snoc126 g a) a\nvz126 = \\ var, vz126, vs => vz126 _ _\n\nvs126 : {g : _} -> {B : _} -> {a : _} -> Var126 g a -> Var126 (snoc126 g B) a\nvs126 = \\ x, var, vz126, vs126 => vs126 _ _ _ (x var vz126 vs126)\n\nTm126 : Con126 -> Ty126 -> Type\nTm126 = \\ g, a =>\n (Tm126 : Con126 -> Ty126 -> Type)\n -> (var : (g : _) -> (a : _) -> Var126 g a -> Tm126 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm126 (snoc126 g a) B -> Tm126 g (arr126 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm126 g (arr126 a B) -> Tm126 g a -> Tm126 g B)\n -> Tm126 g a\n\nvar126 : {g : _} -> {a : _} -> Var126 g a -> Tm126 g a\nvar126 = \\ x, tm, var126, lam, app => var126 _ _ x\n\nlam126 : {g : _} -> {a : _} -> {B : _} -> Tm126 (snoc126 g a) B -> Tm126 g (arr126 a B)\nlam126 = \\ t, tm, var126, lam126, app => lam126 _ _ _ (t tm var126 lam126 app)\n\napp126 : {g:_}->{a:_}->{B:_} -> Tm126 g (arr126 a B) -> Tm126 g a -> Tm126 g B\napp126 = \\ t, u, tm, var126, lam126, app126 => app126 _ _ _ (t tm var126 lam126 app126) (u tm var126 lam126 app126)\n\nv0126 : {g:_}->{a:_} -> Tm126 (snoc126 g a) a\nv0126 = var126 vz126\n\nv1126 : {g:_}->{a:_}-> {B:_}-> Tm126 (snoc126 (snoc126 g a) B) a\nv1126 = var126 (vs126 vz126)\n\nv2126 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm126 (snoc126 (snoc126 (snoc126 g a) B) C) a\nv2126 = var126 (vs126 (vs126 vz126))\n\nv3126 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm126 (snoc126 (snoc126 (snoc126 (snoc126 g a) B) C) D) a\nv3126 = var126 (vs126 (vs126 (vs126 vz126)))\n\nv4126 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm126 (snoc126 (snoc126 (snoc126 (snoc126 (snoc126 g a) B) C) D) E) a\nv4126 = var126 (vs126 (vs126 (vs126 (vs126 vz126))))\n\ntest126 : {g:_}-> {a:_} -> Tm126 g (arr126 (arr126 a a) (arr126 a a))\ntest126 = lam126 (lam126 (app126 v1126 (app126 v1126 (app126 v1126 (app126 v1126 (app126 v1126 (app126 v1126 v0126)))))))\nTy127 : Type\nTy127 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty127 : Ty127\nempty127 = \\ _, empty, _ => empty\n\narr127 : Ty127 -> Ty127 -> Ty127\narr127 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon127 : Type\nCon127 = (Con127 : Type)\n ->(nil : Con127)\n ->(snoc : Con127 -> Ty127 -> Con127)\n -> Con127\n\nnil127 : Con127\nnil127 = \\ con, nil127, snoc => nil127\n\nsnoc127 : Con127 -> Ty127 -> Con127\nsnoc127 = \\ g, a, con, nil127, snoc127 => snoc127 (g con nil127 snoc127) a\n\nVar127 : Con127 -> Ty127 -> Type\nVar127 = \\ g, a =>\n (Var127 : Con127 -> Ty127 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var127 (snoc127 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var127 g a -> Var127 (snoc127 g b) a)\n -> Var127 g a\n\nvz127 : {g : _}-> {a : _} -> Var127 (snoc127 g a) a\nvz127 = \\ var, vz127, vs => vz127 _ _\n\nvs127 : {g : _} -> {B : _} -> {a : _} -> Var127 g a -> Var127 (snoc127 g B) a\nvs127 = \\ x, var, vz127, vs127 => vs127 _ _ _ (x var vz127 vs127)\n\nTm127 : Con127 -> Ty127 -> Type\nTm127 = \\ g, a =>\n (Tm127 : Con127 -> Ty127 -> Type)\n -> (var : (g : _) -> (a : _) -> Var127 g a -> Tm127 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm127 (snoc127 g a) B -> Tm127 g (arr127 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm127 g (arr127 a B) -> Tm127 g a -> Tm127 g B)\n -> Tm127 g a\n\nvar127 : {g : _} -> {a : _} -> Var127 g a -> Tm127 g a\nvar127 = \\ x, tm, var127, lam, app => var127 _ _ x\n\nlam127 : {g : _} -> {a : _} -> {B : _} -> Tm127 (snoc127 g a) B -> Tm127 g (arr127 a B)\nlam127 = \\ t, tm, var127, lam127, app => lam127 _ _ _ (t tm var127 lam127 app)\n\napp127 : {g:_}->{a:_}->{B:_} -> Tm127 g (arr127 a B) -> Tm127 g a -> Tm127 g B\napp127 = \\ t, u, tm, var127, lam127, app127 => app127 _ _ _ (t tm var127 lam127 app127) (u tm var127 lam127 app127)\n\nv0127 : {g:_}->{a:_} -> Tm127 (snoc127 g a) a\nv0127 = var127 vz127\n\nv1127 : {g:_}->{a:_}-> {B:_}-> Tm127 (snoc127 (snoc127 g a) B) a\nv1127 = var127 (vs127 vz127)\n\nv2127 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm127 (snoc127 (snoc127 (snoc127 g a) B) C) a\nv2127 = var127 (vs127 (vs127 vz127))\n\nv3127 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm127 (snoc127 (snoc127 (snoc127 (snoc127 g a) B) C) D) a\nv3127 = var127 (vs127 (vs127 (vs127 vz127)))\n\nv4127 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm127 (snoc127 (snoc127 (snoc127 (snoc127 (snoc127 g a) B) C) D) E) a\nv4127 = var127 (vs127 (vs127 (vs127 (vs127 vz127))))\n\ntest127 : {g:_}-> {a:_} -> Tm127 g (arr127 (arr127 a a) (arr127 a a))\ntest127 = lam127 (lam127 (app127 v1127 (app127 v1127 (app127 v1127 (app127 v1127 (app127 v1127 (app127 v1127 v0127)))))))\nTy128 : Type\nTy128 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty128 : Ty128\nempty128 = \\ _, empty, _ => empty\n\narr128 : Ty128 -> Ty128 -> Ty128\narr128 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon128 : Type\nCon128 = (Con128 : Type)\n ->(nil : Con128)\n ->(snoc : Con128 -> Ty128 -> Con128)\n -> Con128\n\nnil128 : Con128\nnil128 = \\ con, nil128, snoc => nil128\n\nsnoc128 : Con128 -> Ty128 -> Con128\nsnoc128 = \\ g, a, con, nil128, snoc128 => snoc128 (g con nil128 snoc128) a\n\nVar128 : Con128 -> Ty128 -> Type\nVar128 = \\ g, a =>\n (Var128 : Con128 -> Ty128 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var128 (snoc128 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var128 g a -> Var128 (snoc128 g b) a)\n -> Var128 g a\n\nvz128 : {g : _}-> {a : _} -> Var128 (snoc128 g a) a\nvz128 = \\ var, vz128, vs => vz128 _ _\n\nvs128 : {g : _} -> {B : _} -> {a : _} -> Var128 g a -> Var128 (snoc128 g B) a\nvs128 = \\ x, var, vz128, vs128 => vs128 _ _ _ (x var vz128 vs128)\n\nTm128 : Con128 -> Ty128 -> Type\nTm128 = \\ g, a =>\n (Tm128 : Con128 -> Ty128 -> Type)\n -> (var : (g : _) -> (a : _) -> Var128 g a -> Tm128 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm128 (snoc128 g a) B -> Tm128 g (arr128 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm128 g (arr128 a B) -> Tm128 g a -> Tm128 g B)\n -> Tm128 g a\n\nvar128 : {g : _} -> {a : _} -> Var128 g a -> Tm128 g a\nvar128 = \\ x, tm, var128, lam, app => var128 _ _ x\n\nlam128 : {g : _} -> {a : _} -> {B : _} -> Tm128 (snoc128 g a) B -> Tm128 g (arr128 a B)\nlam128 = \\ t, tm, var128, lam128, app => lam128 _ _ _ (t tm var128 lam128 app)\n\napp128 : {g:_}->{a:_}->{B:_} -> Tm128 g (arr128 a B) -> Tm128 g a -> Tm128 g B\napp128 = \\ t, u, tm, var128, lam128, app128 => app128 _ _ _ (t tm var128 lam128 app128) (u tm var128 lam128 app128)\n\nv0128 : {g:_}->{a:_} -> Tm128 (snoc128 g a) a\nv0128 = var128 vz128\n\nv1128 : {g:_}->{a:_}-> {B:_}-> Tm128 (snoc128 (snoc128 g a) B) a\nv1128 = var128 (vs128 vz128)\n\nv2128 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm128 (snoc128 (snoc128 (snoc128 g a) B) C) a\nv2128 = var128 (vs128 (vs128 vz128))\n\nv3128 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm128 (snoc128 (snoc128 (snoc128 (snoc128 g a) B) C) D) a\nv3128 = var128 (vs128 (vs128 (vs128 vz128)))\n\nv4128 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm128 (snoc128 (snoc128 (snoc128 (snoc128 (snoc128 g a) B) C) D) E) a\nv4128 = var128 (vs128 (vs128 (vs128 (vs128 vz128))))\n\ntest128 : {g:_}-> {a:_} -> Tm128 g (arr128 (arr128 a a) (arr128 a a))\ntest128 = lam128 (lam128 (app128 v1128 (app128 v1128 (app128 v1128 (app128 v1128 (app128 v1128 (app128 v1128 v0128)))))))\nTy129 : Type\nTy129 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty129 : Ty129\nempty129 = \\ _, empty, _ => empty\n\narr129 : Ty129 -> Ty129 -> Ty129\narr129 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon129 : Type\nCon129 = (Con129 : Type)\n ->(nil : Con129)\n ->(snoc : Con129 -> Ty129 -> Con129)\n -> Con129\n\nnil129 : Con129\nnil129 = \\ con, nil129, snoc => nil129\n\nsnoc129 : Con129 -> Ty129 -> Con129\nsnoc129 = \\ g, a, con, nil129, snoc129 => snoc129 (g con nil129 snoc129) a\n\nVar129 : Con129 -> Ty129 -> Type\nVar129 = \\ g, a =>\n (Var129 : Con129 -> Ty129 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var129 (snoc129 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var129 g a -> Var129 (snoc129 g b) a)\n -> Var129 g a\n\nvz129 : {g : _}-> {a : _} -> Var129 (snoc129 g a) a\nvz129 = \\ var, vz129, vs => vz129 _ _\n\nvs129 : {g : _} -> {B : _} -> {a : _} -> Var129 g a -> Var129 (snoc129 g B) a\nvs129 = \\ x, var, vz129, vs129 => vs129 _ _ _ (x var vz129 vs129)\n\nTm129 : Con129 -> Ty129 -> Type\nTm129 = \\ g, a =>\n (Tm129 : Con129 -> Ty129 -> Type)\n -> (var : (g : _) -> (a : _) -> Var129 g a -> Tm129 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm129 (snoc129 g a) B -> Tm129 g (arr129 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm129 g (arr129 a B) -> Tm129 g a -> Tm129 g B)\n -> Tm129 g a\n\nvar129 : {g : _} -> {a : _} -> Var129 g a -> Tm129 g a\nvar129 = \\ x, tm, var129, lam, app => var129 _ _ x\n\nlam129 : {g : _} -> {a : _} -> {B : _} -> Tm129 (snoc129 g a) B -> Tm129 g (arr129 a B)\nlam129 = \\ t, tm, var129, lam129, app => lam129 _ _ _ (t tm var129 lam129 app)\n\napp129 : {g:_}->{a:_}->{B:_} -> Tm129 g (arr129 a B) -> Tm129 g a -> Tm129 g B\napp129 = \\ t, u, tm, var129, lam129, app129 => app129 _ _ _ (t tm var129 lam129 app129) (u tm var129 lam129 app129)\n\nv0129 : {g:_}->{a:_} -> Tm129 (snoc129 g a) a\nv0129 = var129 vz129\n\nv1129 : {g:_}->{a:_}-> {B:_}-> Tm129 (snoc129 (snoc129 g a) B) a\nv1129 = var129 (vs129 vz129)\n\nv2129 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm129 (snoc129 (snoc129 (snoc129 g a) B) C) a\nv2129 = var129 (vs129 (vs129 vz129))\n\nv3129 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm129 (snoc129 (snoc129 (snoc129 (snoc129 g a) B) C) D) a\nv3129 = var129 (vs129 (vs129 (vs129 vz129)))\n\nv4129 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm129 (snoc129 (snoc129 (snoc129 (snoc129 (snoc129 g a) B) C) D) E) a\nv4129 = var129 (vs129 (vs129 (vs129 (vs129 vz129))))\n\ntest129 : {g:_}-> {a:_} -> Tm129 g (arr129 (arr129 a a) (arr129 a a))\ntest129 = lam129 (lam129 (app129 v1129 (app129 v1129 (app129 v1129 (app129 v1129 (app129 v1129 (app129 v1129 v0129)))))))\nTy130 : Type\nTy130 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty130 : Ty130\nempty130 = \\ _, empty, _ => empty\n\narr130 : Ty130 -> Ty130 -> Ty130\narr130 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon130 : Type\nCon130 = (Con130 : Type)\n ->(nil : Con130)\n ->(snoc : Con130 -> Ty130 -> Con130)\n -> Con130\n\nnil130 : Con130\nnil130 = \\ con, nil130, snoc => nil130\n\nsnoc130 : Con130 -> Ty130 -> Con130\nsnoc130 = \\ g, a, con, nil130, snoc130 => snoc130 (g con nil130 snoc130) a\n\nVar130 : Con130 -> Ty130 -> Type\nVar130 = \\ g, a =>\n (Var130 : Con130 -> Ty130 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var130 (snoc130 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var130 g a -> Var130 (snoc130 g b) a)\n -> Var130 g a\n\nvz130 : {g : _}-> {a : _} -> Var130 (snoc130 g a) a\nvz130 = \\ var, vz130, vs => vz130 _ _\n\nvs130 : {g : _} -> {B : _} -> {a : _} -> Var130 g a -> Var130 (snoc130 g B) a\nvs130 = \\ x, var, vz130, vs130 => vs130 _ _ _ (x var vz130 vs130)\n\nTm130 : Con130 -> Ty130 -> Type\nTm130 = \\ g, a =>\n (Tm130 : Con130 -> Ty130 -> Type)\n -> (var : (g : _) -> (a : _) -> Var130 g a -> Tm130 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm130 (snoc130 g a) B -> Tm130 g (arr130 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm130 g (arr130 a B) -> Tm130 g a -> Tm130 g B)\n -> Tm130 g a\n\nvar130 : {g : _} -> {a : _} -> Var130 g a -> Tm130 g a\nvar130 = \\ x, tm, var130, lam, app => var130 _ _ x\n\nlam130 : {g : _} -> {a : _} -> {B : _} -> Tm130 (snoc130 g a) B -> Tm130 g (arr130 a B)\nlam130 = \\ t, tm, var130, lam130, app => lam130 _ _ _ (t tm var130 lam130 app)\n\napp130 : {g:_}->{a:_}->{B:_} -> Tm130 g (arr130 a B) -> Tm130 g a -> Tm130 g B\napp130 = \\ t, u, tm, var130, lam130, app130 => app130 _ _ _ (t tm var130 lam130 app130) (u tm var130 lam130 app130)\n\nv0130 : {g:_}->{a:_} -> Tm130 (snoc130 g a) a\nv0130 = var130 vz130\n\nv1130 : {g:_}->{a:_}-> {B:_}-> Tm130 (snoc130 (snoc130 g a) B) a\nv1130 = var130 (vs130 vz130)\n\nv2130 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm130 (snoc130 (snoc130 (snoc130 g a) B) C) a\nv2130 = var130 (vs130 (vs130 vz130))\n\nv3130 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm130 (snoc130 (snoc130 (snoc130 (snoc130 g a) B) C) D) a\nv3130 = var130 (vs130 (vs130 (vs130 vz130)))\n\nv4130 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm130 (snoc130 (snoc130 (snoc130 (snoc130 (snoc130 g a) B) C) D) E) a\nv4130 = var130 (vs130 (vs130 (vs130 (vs130 vz130))))\n\ntest130 : {g:_}-> {a:_} -> Tm130 g (arr130 (arr130 a a) (arr130 a a))\ntest130 = lam130 (lam130 (app130 v1130 (app130 v1130 (app130 v1130 (app130 v1130 (app130 v1130 (app130 v1130 v0130)))))))\nTy131 : Type\nTy131 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty131 : Ty131\nempty131 = \\ _, empty, _ => empty\n\narr131 : Ty131 -> Ty131 -> Ty131\narr131 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon131 : Type\nCon131 = (Con131 : Type)\n ->(nil : Con131)\n ->(snoc : Con131 -> Ty131 -> Con131)\n -> Con131\n\nnil131 : Con131\nnil131 = \\ con, nil131, snoc => nil131\n\nsnoc131 : Con131 -> Ty131 -> Con131\nsnoc131 = \\ g, a, con, nil131, snoc131 => snoc131 (g con nil131 snoc131) a\n\nVar131 : Con131 -> Ty131 -> Type\nVar131 = \\ g, a =>\n (Var131 : Con131 -> Ty131 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var131 (snoc131 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var131 g a -> Var131 (snoc131 g b) a)\n -> Var131 g a\n\nvz131 : {g : _}-> {a : _} -> Var131 (snoc131 g a) a\nvz131 = \\ var, vz131, vs => vz131 _ _\n\nvs131 : {g : _} -> {B : _} -> {a : _} -> Var131 g a -> Var131 (snoc131 g B) a\nvs131 = \\ x, var, vz131, vs131 => vs131 _ _ _ (x var vz131 vs131)\n\nTm131 : Con131 -> Ty131 -> Type\nTm131 = \\ g, a =>\n (Tm131 : Con131 -> Ty131 -> Type)\n -> (var : (g : _) -> (a : _) -> Var131 g a -> Tm131 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm131 (snoc131 g a) B -> Tm131 g (arr131 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm131 g (arr131 a B) -> Tm131 g a -> Tm131 g B)\n -> Tm131 g a\n\nvar131 : {g : _} -> {a : _} -> Var131 g a -> Tm131 g a\nvar131 = \\ x, tm, var131, lam, app => var131 _ _ x\n\nlam131 : {g : _} -> {a : _} -> {B : _} -> Tm131 (snoc131 g a) B -> Tm131 g (arr131 a B)\nlam131 = \\ t, tm, var131, lam131, app => lam131 _ _ _ (t tm var131 lam131 app)\n\napp131 : {g:_}->{a:_}->{B:_} -> Tm131 g (arr131 a B) -> Tm131 g a -> Tm131 g B\napp131 = \\ t, u, tm, var131, lam131, app131 => app131 _ _ _ (t tm var131 lam131 app131) (u tm var131 lam131 app131)\n\nv0131 : {g:_}->{a:_} -> Tm131 (snoc131 g a) a\nv0131 = var131 vz131\n\nv1131 : {g:_}->{a:_}-> {B:_}-> Tm131 (snoc131 (snoc131 g a) B) a\nv1131 = var131 (vs131 vz131)\n\nv2131 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm131 (snoc131 (snoc131 (snoc131 g a) B) C) a\nv2131 = var131 (vs131 (vs131 vz131))\n\nv3131 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm131 (snoc131 (snoc131 (snoc131 (snoc131 g a) B) C) D) a\nv3131 = var131 (vs131 (vs131 (vs131 vz131)))\n\nv4131 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm131 (snoc131 (snoc131 (snoc131 (snoc131 (snoc131 g a) B) C) D) E) a\nv4131 = var131 (vs131 (vs131 (vs131 (vs131 vz131))))\n\ntest131 : {g:_}-> {a:_} -> Tm131 g (arr131 (arr131 a a) (arr131 a a))\ntest131 = lam131 (lam131 (app131 v1131 (app131 v1131 (app131 v1131 (app131 v1131 (app131 v1131 (app131 v1131 v0131)))))))\nTy132 : Type\nTy132 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty132 : Ty132\nempty132 = \\ _, empty, _ => empty\n\narr132 : Ty132 -> Ty132 -> Ty132\narr132 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon132 : Type\nCon132 = (Con132 : Type)\n ->(nil : Con132)\n ->(snoc : Con132 -> Ty132 -> Con132)\n -> Con132\n\nnil132 : Con132\nnil132 = \\ con, nil132, snoc => nil132\n\nsnoc132 : Con132 -> Ty132 -> Con132\nsnoc132 = \\ g, a, con, nil132, snoc132 => snoc132 (g con nil132 snoc132) a\n\nVar132 : Con132 -> Ty132 -> Type\nVar132 = \\ g, a =>\n (Var132 : Con132 -> Ty132 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var132 (snoc132 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var132 g a -> Var132 (snoc132 g b) a)\n -> Var132 g a\n\nvz132 : {g : _}-> {a : _} -> Var132 (snoc132 g a) a\nvz132 = \\ var, vz132, vs => vz132 _ _\n\nvs132 : {g : _} -> {B : _} -> {a : _} -> Var132 g a -> Var132 (snoc132 g B) a\nvs132 = \\ x, var, vz132, vs132 => vs132 _ _ _ (x var vz132 vs132)\n\nTm132 : Con132 -> Ty132 -> Type\nTm132 = \\ g, a =>\n (Tm132 : Con132 -> Ty132 -> Type)\n -> (var : (g : _) -> (a : _) -> Var132 g a -> Tm132 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm132 (snoc132 g a) B -> Tm132 g (arr132 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm132 g (arr132 a B) -> Tm132 g a -> Tm132 g B)\n -> Tm132 g a\n\nvar132 : {g : _} -> {a : _} -> Var132 g a -> Tm132 g a\nvar132 = \\ x, tm, var132, lam, app => var132 _ _ x\n\nlam132 : {g : _} -> {a : _} -> {B : _} -> Tm132 (snoc132 g a) B -> Tm132 g (arr132 a B)\nlam132 = \\ t, tm, var132, lam132, app => lam132 _ _ _ (t tm var132 lam132 app)\n\napp132 : {g:_}->{a:_}->{B:_} -> Tm132 g (arr132 a B) -> Tm132 g a -> Tm132 g B\napp132 = \\ t, u, tm, var132, lam132, app132 => app132 _ _ _ (t tm var132 lam132 app132) (u tm var132 lam132 app132)\n\nv0132 : {g:_}->{a:_} -> Tm132 (snoc132 g a) a\nv0132 = var132 vz132\n\nv1132 : {g:_}->{a:_}-> {B:_}-> Tm132 (snoc132 (snoc132 g a) B) a\nv1132 = var132 (vs132 vz132)\n\nv2132 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm132 (snoc132 (snoc132 (snoc132 g a) B) C) a\nv2132 = var132 (vs132 (vs132 vz132))\n\nv3132 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm132 (snoc132 (snoc132 (snoc132 (snoc132 g a) B) C) D) a\nv3132 = var132 (vs132 (vs132 (vs132 vz132)))\n\nv4132 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm132 (snoc132 (snoc132 (snoc132 (snoc132 (snoc132 g a) B) C) D) E) a\nv4132 = var132 (vs132 (vs132 (vs132 (vs132 vz132))))\n\ntest132 : {g:_}-> {a:_} -> Tm132 g (arr132 (arr132 a a) (arr132 a a))\ntest132 = lam132 (lam132 (app132 v1132 (app132 v1132 (app132 v1132 (app132 v1132 (app132 v1132 (app132 v1132 v0132)))))))\nTy133 : Type\nTy133 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty133 : Ty133\nempty133 = \\ _, empty, _ => empty\n\narr133 : Ty133 -> Ty133 -> Ty133\narr133 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon133 : Type\nCon133 = (Con133 : Type)\n ->(nil : Con133)\n ->(snoc : Con133 -> Ty133 -> Con133)\n -> Con133\n\nnil133 : Con133\nnil133 = \\ con, nil133, snoc => nil133\n\nsnoc133 : Con133 -> Ty133 -> Con133\nsnoc133 = \\ g, a, con, nil133, snoc133 => snoc133 (g con nil133 snoc133) a\n\nVar133 : Con133 -> Ty133 -> Type\nVar133 = \\ g, a =>\n (Var133 : Con133 -> Ty133 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var133 (snoc133 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var133 g a -> Var133 (snoc133 g b) a)\n -> Var133 g a\n\nvz133 : {g : _}-> {a : _} -> Var133 (snoc133 g a) a\nvz133 = \\ var, vz133, vs => vz133 _ _\n\nvs133 : {g : _} -> {B : _} -> {a : _} -> Var133 g a -> Var133 (snoc133 g B) a\nvs133 = \\ x, var, vz133, vs133 => vs133 _ _ _ (x var vz133 vs133)\n\nTm133 : Con133 -> Ty133 -> Type\nTm133 = \\ g, a =>\n (Tm133 : Con133 -> Ty133 -> Type)\n -> (var : (g : _) -> (a : _) -> Var133 g a -> Tm133 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm133 (snoc133 g a) B -> Tm133 g (arr133 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm133 g (arr133 a B) -> Tm133 g a -> Tm133 g B)\n -> Tm133 g a\n\nvar133 : {g : _} -> {a : _} -> Var133 g a -> Tm133 g a\nvar133 = \\ x, tm, var133, lam, app => var133 _ _ x\n\nlam133 : {g : _} -> {a : _} -> {B : _} -> Tm133 (snoc133 g a) B -> Tm133 g (arr133 a B)\nlam133 = \\ t, tm, var133, lam133, app => lam133 _ _ _ (t tm var133 lam133 app)\n\napp133 : {g:_}->{a:_}->{B:_} -> Tm133 g (arr133 a B) -> Tm133 g a -> Tm133 g B\napp133 = \\ t, u, tm, var133, lam133, app133 => app133 _ _ _ (t tm var133 lam133 app133) (u tm var133 lam133 app133)\n\nv0133 : {g:_}->{a:_} -> Tm133 (snoc133 g a) a\nv0133 = var133 vz133\n\nv1133 : {g:_}->{a:_}-> {B:_}-> Tm133 (snoc133 (snoc133 g a) B) a\nv1133 = var133 (vs133 vz133)\n\nv2133 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm133 (snoc133 (snoc133 (snoc133 g a) B) C) a\nv2133 = var133 (vs133 (vs133 vz133))\n\nv3133 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm133 (snoc133 (snoc133 (snoc133 (snoc133 g a) B) C) D) a\nv3133 = var133 (vs133 (vs133 (vs133 vz133)))\n\nv4133 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm133 (snoc133 (snoc133 (snoc133 (snoc133 (snoc133 g a) B) C) D) E) a\nv4133 = var133 (vs133 (vs133 (vs133 (vs133 vz133))))\n\ntest133 : {g:_}-> {a:_} -> Tm133 g (arr133 (arr133 a a) (arr133 a a))\ntest133 = lam133 (lam133 (app133 v1133 (app133 v1133 (app133 v1133 (app133 v1133 (app133 v1133 (app133 v1133 v0133)))))))\nTy134 : Type\nTy134 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty134 : Ty134\nempty134 = \\ _, empty, _ => empty\n\narr134 : Ty134 -> Ty134 -> Ty134\narr134 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon134 : Type\nCon134 = (Con134 : Type)\n ->(nil : Con134)\n ->(snoc : Con134 -> Ty134 -> Con134)\n -> Con134\n\nnil134 : Con134\nnil134 = \\ con, nil134, snoc => nil134\n\nsnoc134 : Con134 -> Ty134 -> Con134\nsnoc134 = \\ g, a, con, nil134, snoc134 => snoc134 (g con nil134 snoc134) a\n\nVar134 : Con134 -> Ty134 -> Type\nVar134 = \\ g, a =>\n (Var134 : Con134 -> Ty134 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var134 (snoc134 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var134 g a -> Var134 (snoc134 g b) a)\n -> Var134 g a\n\nvz134 : {g : _}-> {a : _} -> Var134 (snoc134 g a) a\nvz134 = \\ var, vz134, vs => vz134 _ _\n\nvs134 : {g : _} -> {B : _} -> {a : _} -> Var134 g a -> Var134 (snoc134 g B) a\nvs134 = \\ x, var, vz134, vs134 => vs134 _ _ _ (x var vz134 vs134)\n\nTm134 : Con134 -> Ty134 -> Type\nTm134 = \\ g, a =>\n (Tm134 : Con134 -> Ty134 -> Type)\n -> (var : (g : _) -> (a : _) -> Var134 g a -> Tm134 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm134 (snoc134 g a) B -> Tm134 g (arr134 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm134 g (arr134 a B) -> Tm134 g a -> Tm134 g B)\n -> Tm134 g a\n\nvar134 : {g : _} -> {a : _} -> Var134 g a -> Tm134 g a\nvar134 = \\ x, tm, var134, lam, app => var134 _ _ x\n\nlam134 : {g : _} -> {a : _} -> {B : _} -> Tm134 (snoc134 g a) B -> Tm134 g (arr134 a B)\nlam134 = \\ t, tm, var134, lam134, app => lam134 _ _ _ (t tm var134 lam134 app)\n\napp134 : {g:_}->{a:_}->{B:_} -> Tm134 g (arr134 a B) -> Tm134 g a -> Tm134 g B\napp134 = \\ t, u, tm, var134, lam134, app134 => app134 _ _ _ (t tm var134 lam134 app134) (u tm var134 lam134 app134)\n\nv0134 : {g:_}->{a:_} -> Tm134 (snoc134 g a) a\nv0134 = var134 vz134\n\nv1134 : {g:_}->{a:_}-> {B:_}-> Tm134 (snoc134 (snoc134 g a) B) a\nv1134 = var134 (vs134 vz134)\n\nv2134 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm134 (snoc134 (snoc134 (snoc134 g a) B) C) a\nv2134 = var134 (vs134 (vs134 vz134))\n\nv3134 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm134 (snoc134 (snoc134 (snoc134 (snoc134 g a) B) C) D) a\nv3134 = var134 (vs134 (vs134 (vs134 vz134)))\n\nv4134 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm134 (snoc134 (snoc134 (snoc134 (snoc134 (snoc134 g a) B) C) D) E) a\nv4134 = var134 (vs134 (vs134 (vs134 (vs134 vz134))))\n\ntest134 : {g:_}-> {a:_} -> Tm134 g (arr134 (arr134 a a) (arr134 a a))\ntest134 = lam134 (lam134 (app134 v1134 (app134 v1134 (app134 v1134 (app134 v1134 (app134 v1134 (app134 v1134 v0134)))))))\nTy135 : Type\nTy135 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty135 : Ty135\nempty135 = \\ _, empty, _ => empty\n\narr135 : Ty135 -> Ty135 -> Ty135\narr135 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon135 : Type\nCon135 = (Con135 : Type)\n ->(nil : Con135)\n ->(snoc : Con135 -> Ty135 -> Con135)\n -> Con135\n\nnil135 : Con135\nnil135 = \\ con, nil135, snoc => nil135\n\nsnoc135 : Con135 -> Ty135 -> Con135\nsnoc135 = \\ g, a, con, nil135, snoc135 => snoc135 (g con nil135 snoc135) a\n\nVar135 : Con135 -> Ty135 -> Type\nVar135 = \\ g, a =>\n (Var135 : Con135 -> Ty135 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var135 (snoc135 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var135 g a -> Var135 (snoc135 g b) a)\n -> Var135 g a\n\nvz135 : {g : _}-> {a : _} -> Var135 (snoc135 g a) a\nvz135 = \\ var, vz135, vs => vz135 _ _\n\nvs135 : {g : _} -> {B : _} -> {a : _} -> Var135 g a -> Var135 (snoc135 g B) a\nvs135 = \\ x, var, vz135, vs135 => vs135 _ _ _ (x var vz135 vs135)\n\nTm135 : Con135 -> Ty135 -> Type\nTm135 = \\ g, a =>\n (Tm135 : Con135 -> Ty135 -> Type)\n -> (var : (g : _) -> (a : _) -> Var135 g a -> Tm135 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm135 (snoc135 g a) B -> Tm135 g (arr135 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm135 g (arr135 a B) -> Tm135 g a -> Tm135 g B)\n -> Tm135 g a\n\nvar135 : {g : _} -> {a : _} -> Var135 g a -> Tm135 g a\nvar135 = \\ x, tm, var135, lam, app => var135 _ _ x\n\nlam135 : {g : _} -> {a : _} -> {B : _} -> Tm135 (snoc135 g a) B -> Tm135 g (arr135 a B)\nlam135 = \\ t, tm, var135, lam135, app => lam135 _ _ _ (t tm var135 lam135 app)\n\napp135 : {g:_}->{a:_}->{B:_} -> Tm135 g (arr135 a B) -> Tm135 g a -> Tm135 g B\napp135 = \\ t, u, tm, var135, lam135, app135 => app135 _ _ _ (t tm var135 lam135 app135) (u tm var135 lam135 app135)\n\nv0135 : {g:_}->{a:_} -> Tm135 (snoc135 g a) a\nv0135 = var135 vz135\n\nv1135 : {g:_}->{a:_}-> {B:_}-> Tm135 (snoc135 (snoc135 g a) B) a\nv1135 = var135 (vs135 vz135)\n\nv2135 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm135 (snoc135 (snoc135 (snoc135 g a) B) C) a\nv2135 = var135 (vs135 (vs135 vz135))\n\nv3135 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm135 (snoc135 (snoc135 (snoc135 (snoc135 g a) B) C) D) a\nv3135 = var135 (vs135 (vs135 (vs135 vz135)))\n\nv4135 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm135 (snoc135 (snoc135 (snoc135 (snoc135 (snoc135 g a) B) C) D) E) a\nv4135 = var135 (vs135 (vs135 (vs135 (vs135 vz135))))\n\ntest135 : {g:_}-> {a:_} -> Tm135 g (arr135 (arr135 a a) (arr135 a a))\ntest135 = lam135 (lam135 (app135 v1135 (app135 v1135 (app135 v1135 (app135 v1135 (app135 v1135 (app135 v1135 v0135)))))))\nTy136 : Type\nTy136 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty136 : Ty136\nempty136 = \\ _, empty, _ => empty\n\narr136 : Ty136 -> Ty136 -> Ty136\narr136 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon136 : Type\nCon136 = (Con136 : Type)\n ->(nil : Con136)\n ->(snoc : Con136 -> Ty136 -> Con136)\n -> Con136\n\nnil136 : Con136\nnil136 = \\ con, nil136, snoc => nil136\n\nsnoc136 : Con136 -> Ty136 -> Con136\nsnoc136 = \\ g, a, con, nil136, snoc136 => snoc136 (g con nil136 snoc136) a\n\nVar136 : Con136 -> Ty136 -> Type\nVar136 = \\ g, a =>\n (Var136 : Con136 -> Ty136 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var136 (snoc136 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var136 g a -> Var136 (snoc136 g b) a)\n -> Var136 g a\n\nvz136 : {g : _}-> {a : _} -> Var136 (snoc136 g a) a\nvz136 = \\ var, vz136, vs => vz136 _ _\n\nvs136 : {g : _} -> {B : _} -> {a : _} -> Var136 g a -> Var136 (snoc136 g B) a\nvs136 = \\ x, var, vz136, vs136 => vs136 _ _ _ (x var vz136 vs136)\n\nTm136 : Con136 -> Ty136 -> Type\nTm136 = \\ g, a =>\n (Tm136 : Con136 -> Ty136 -> Type)\n -> (var : (g : _) -> (a : _) -> Var136 g a -> Tm136 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm136 (snoc136 g a) B -> Tm136 g (arr136 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm136 g (arr136 a B) -> Tm136 g a -> Tm136 g B)\n -> Tm136 g a\n\nvar136 : {g : _} -> {a : _} -> Var136 g a -> Tm136 g a\nvar136 = \\ x, tm, var136, lam, app => var136 _ _ x\n\nlam136 : {g : _} -> {a : _} -> {B : _} -> Tm136 (snoc136 g a) B -> Tm136 g (arr136 a B)\nlam136 = \\ t, tm, var136, lam136, app => lam136 _ _ _ (t tm var136 lam136 app)\n\napp136 : {g:_}->{a:_}->{B:_} -> Tm136 g (arr136 a B) -> Tm136 g a -> Tm136 g B\napp136 = \\ t, u, tm, var136, lam136, app136 => app136 _ _ _ (t tm var136 lam136 app136) (u tm var136 lam136 app136)\n\nv0136 : {g:_}->{a:_} -> Tm136 (snoc136 g a) a\nv0136 = var136 vz136\n\nv1136 : {g:_}->{a:_}-> {B:_}-> Tm136 (snoc136 (snoc136 g a) B) a\nv1136 = var136 (vs136 vz136)\n\nv2136 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm136 (snoc136 (snoc136 (snoc136 g a) B) C) a\nv2136 = var136 (vs136 (vs136 vz136))\n\nv3136 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm136 (snoc136 (snoc136 (snoc136 (snoc136 g a) B) C) D) a\nv3136 = var136 (vs136 (vs136 (vs136 vz136)))\n\nv4136 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm136 (snoc136 (snoc136 (snoc136 (snoc136 (snoc136 g a) B) C) D) E) a\nv4136 = var136 (vs136 (vs136 (vs136 (vs136 vz136))))\n\ntest136 : {g:_}-> {a:_} -> Tm136 g (arr136 (arr136 a a) (arr136 a a))\ntest136 = lam136 (lam136 (app136 v1136 (app136 v1136 (app136 v1136 (app136 v1136 (app136 v1136 (app136 v1136 v0136)))))))\nTy137 : Type\nTy137 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty137 : Ty137\nempty137 = \\ _, empty, _ => empty\n\narr137 : Ty137 -> Ty137 -> Ty137\narr137 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon137 : Type\nCon137 = (Con137 : Type)\n ->(nil : Con137)\n ->(snoc : Con137 -> Ty137 -> Con137)\n -> Con137\n\nnil137 : Con137\nnil137 = \\ con, nil137, snoc => nil137\n\nsnoc137 : Con137 -> Ty137 -> Con137\nsnoc137 = \\ g, a, con, nil137, snoc137 => snoc137 (g con nil137 snoc137) a\n\nVar137 : Con137 -> Ty137 -> Type\nVar137 = \\ g, a =>\n (Var137 : Con137 -> Ty137 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var137 (snoc137 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var137 g a -> Var137 (snoc137 g b) a)\n -> Var137 g a\n\nvz137 : {g : _}-> {a : _} -> Var137 (snoc137 g a) a\nvz137 = \\ var, vz137, vs => vz137 _ _\n\nvs137 : {g : _} -> {B : _} -> {a : _} -> Var137 g a -> Var137 (snoc137 g B) a\nvs137 = \\ x, var, vz137, vs137 => vs137 _ _ _ (x var vz137 vs137)\n\nTm137 : Con137 -> Ty137 -> Type\nTm137 = \\ g, a =>\n (Tm137 : Con137 -> Ty137 -> Type)\n -> (var : (g : _) -> (a : _) -> Var137 g a -> Tm137 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm137 (snoc137 g a) B -> Tm137 g (arr137 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm137 g (arr137 a B) -> Tm137 g a -> Tm137 g B)\n -> Tm137 g a\n\nvar137 : {g : _} -> {a : _} -> Var137 g a -> Tm137 g a\nvar137 = \\ x, tm, var137, lam, app => var137 _ _ x\n\nlam137 : {g : _} -> {a : _} -> {B : _} -> Tm137 (snoc137 g a) B -> Tm137 g (arr137 a B)\nlam137 = \\ t, tm, var137, lam137, app => lam137 _ _ _ (t tm var137 lam137 app)\n\napp137 : {g:_}->{a:_}->{B:_} -> Tm137 g (arr137 a B) -> Tm137 g a -> Tm137 g B\napp137 = \\ t, u, tm, var137, lam137, app137 => app137 _ _ _ (t tm var137 lam137 app137) (u tm var137 lam137 app137)\n\nv0137 : {g:_}->{a:_} -> Tm137 (snoc137 g a) a\nv0137 = var137 vz137\n\nv1137 : {g:_}->{a:_}-> {B:_}-> Tm137 (snoc137 (snoc137 g a) B) a\nv1137 = var137 (vs137 vz137)\n\nv2137 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm137 (snoc137 (snoc137 (snoc137 g a) B) C) a\nv2137 = var137 (vs137 (vs137 vz137))\n\nv3137 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm137 (snoc137 (snoc137 (snoc137 (snoc137 g a) B) C) D) a\nv3137 = var137 (vs137 (vs137 (vs137 vz137)))\n\nv4137 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm137 (snoc137 (snoc137 (snoc137 (snoc137 (snoc137 g a) B) C) D) E) a\nv4137 = var137 (vs137 (vs137 (vs137 (vs137 vz137))))\n\ntest137 : {g:_}-> {a:_} -> Tm137 g (arr137 (arr137 a a) (arr137 a a))\ntest137 = lam137 (lam137 (app137 v1137 (app137 v1137 (app137 v1137 (app137 v1137 (app137 v1137 (app137 v1137 v0137)))))))\nTy138 : Type\nTy138 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty138 : Ty138\nempty138 = \\ _, empty, _ => empty\n\narr138 : Ty138 -> Ty138 -> Ty138\narr138 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon138 : Type\nCon138 = (Con138 : Type)\n ->(nil : Con138)\n ->(snoc : Con138 -> Ty138 -> Con138)\n -> Con138\n\nnil138 : Con138\nnil138 = \\ con, nil138, snoc => nil138\n\nsnoc138 : Con138 -> Ty138 -> Con138\nsnoc138 = \\ g, a, con, nil138, snoc138 => snoc138 (g con nil138 snoc138) a\n\nVar138 : Con138 -> Ty138 -> Type\nVar138 = \\ g, a =>\n (Var138 : Con138 -> Ty138 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var138 (snoc138 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var138 g a -> Var138 (snoc138 g b) a)\n -> Var138 g a\n\nvz138 : {g : _}-> {a : _} -> Var138 (snoc138 g a) a\nvz138 = \\ var, vz138, vs => vz138 _ _\n\nvs138 : {g : _} -> {B : _} -> {a : _} -> Var138 g a -> Var138 (snoc138 g B) a\nvs138 = \\ x, var, vz138, vs138 => vs138 _ _ _ (x var vz138 vs138)\n\nTm138 : Con138 -> Ty138 -> Type\nTm138 = \\ g, a =>\n (Tm138 : Con138 -> Ty138 -> Type)\n -> (var : (g : _) -> (a : _) -> Var138 g a -> Tm138 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm138 (snoc138 g a) B -> Tm138 g (arr138 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm138 g (arr138 a B) -> Tm138 g a -> Tm138 g B)\n -> Tm138 g a\n\nvar138 : {g : _} -> {a : _} -> Var138 g a -> Tm138 g a\nvar138 = \\ x, tm, var138, lam, app => var138 _ _ x\n\nlam138 : {g : _} -> {a : _} -> {B : _} -> Tm138 (snoc138 g a) B -> Tm138 g (arr138 a B)\nlam138 = \\ t, tm, var138, lam138, app => lam138 _ _ _ (t tm var138 lam138 app)\n\napp138 : {g:_}->{a:_}->{B:_} -> Tm138 g (arr138 a B) -> Tm138 g a -> Tm138 g B\napp138 = \\ t, u, tm, var138, lam138, app138 => app138 _ _ _ (t tm var138 lam138 app138) (u tm var138 lam138 app138)\n\nv0138 : {g:_}->{a:_} -> Tm138 (snoc138 g a) a\nv0138 = var138 vz138\n\nv1138 : {g:_}->{a:_}-> {B:_}-> Tm138 (snoc138 (snoc138 g a) B) a\nv1138 = var138 (vs138 vz138)\n\nv2138 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm138 (snoc138 (snoc138 (snoc138 g a) B) C) a\nv2138 = var138 (vs138 (vs138 vz138))\n\nv3138 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm138 (snoc138 (snoc138 (snoc138 (snoc138 g a) B) C) D) a\nv3138 = var138 (vs138 (vs138 (vs138 vz138)))\n\nv4138 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm138 (snoc138 (snoc138 (snoc138 (snoc138 (snoc138 g a) B) C) D) E) a\nv4138 = var138 (vs138 (vs138 (vs138 (vs138 vz138))))\n\ntest138 : {g:_}-> {a:_} -> Tm138 g (arr138 (arr138 a a) (arr138 a a))\ntest138 = lam138 (lam138 (app138 v1138 (app138 v1138 (app138 v1138 (app138 v1138 (app138 v1138 (app138 v1138 v0138)))))))\nTy139 : Type\nTy139 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty139 : Ty139\nempty139 = \\ _, empty, _ => empty\n\narr139 : Ty139 -> Ty139 -> Ty139\narr139 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon139 : Type\nCon139 = (Con139 : Type)\n ->(nil : Con139)\n ->(snoc : Con139 -> Ty139 -> Con139)\n -> Con139\n\nnil139 : Con139\nnil139 = \\ con, nil139, snoc => nil139\n\nsnoc139 : Con139 -> Ty139 -> Con139\nsnoc139 = \\ g, a, con, nil139, snoc139 => snoc139 (g con nil139 snoc139) a\n\nVar139 : Con139 -> Ty139 -> Type\nVar139 = \\ g, a =>\n (Var139 : Con139 -> Ty139 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var139 (snoc139 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var139 g a -> Var139 (snoc139 g b) a)\n -> Var139 g a\n\nvz139 : {g : _}-> {a : _} -> Var139 (snoc139 g a) a\nvz139 = \\ var, vz139, vs => vz139 _ _\n\nvs139 : {g : _} -> {B : _} -> {a : _} -> Var139 g a -> Var139 (snoc139 g B) a\nvs139 = \\ x, var, vz139, vs139 => vs139 _ _ _ (x var vz139 vs139)\n\nTm139 : Con139 -> Ty139 -> Type\nTm139 = \\ g, a =>\n (Tm139 : Con139 -> Ty139 -> Type)\n -> (var : (g : _) -> (a : _) -> Var139 g a -> Tm139 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm139 (snoc139 g a) B -> Tm139 g (arr139 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm139 g (arr139 a B) -> Tm139 g a -> Tm139 g B)\n -> Tm139 g a\n\nvar139 : {g : _} -> {a : _} -> Var139 g a -> Tm139 g a\nvar139 = \\ x, tm, var139, lam, app => var139 _ _ x\n\nlam139 : {g : _} -> {a : _} -> {B : _} -> Tm139 (snoc139 g a) B -> Tm139 g (arr139 a B)\nlam139 = \\ t, tm, var139, lam139, app => lam139 _ _ _ (t tm var139 lam139 app)\n\napp139 : {g:_}->{a:_}->{B:_} -> Tm139 g (arr139 a B) -> Tm139 g a -> Tm139 g B\napp139 = \\ t, u, tm, var139, lam139, app139 => app139 _ _ _ (t tm var139 lam139 app139) (u tm var139 lam139 app139)\n\nv0139 : {g:_}->{a:_} -> Tm139 (snoc139 g a) a\nv0139 = var139 vz139\n\nv1139 : {g:_}->{a:_}-> {B:_}-> Tm139 (snoc139 (snoc139 g a) B) a\nv1139 = var139 (vs139 vz139)\n\nv2139 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm139 (snoc139 (snoc139 (snoc139 g a) B) C) a\nv2139 = var139 (vs139 (vs139 vz139))\n\nv3139 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm139 (snoc139 (snoc139 (snoc139 (snoc139 g a) B) C) D) a\nv3139 = var139 (vs139 (vs139 (vs139 vz139)))\n\nv4139 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm139 (snoc139 (snoc139 (snoc139 (snoc139 (snoc139 g a) B) C) D) E) a\nv4139 = var139 (vs139 (vs139 (vs139 (vs139 vz139))))\n\ntest139 : {g:_}-> {a:_} -> Tm139 g (arr139 (arr139 a a) (arr139 a a))\ntest139 = lam139 (lam139 (app139 v1139 (app139 v1139 (app139 v1139 (app139 v1139 (app139 v1139 (app139 v1139 v0139)))))))\nTy140 : Type\nTy140 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty140 : Ty140\nempty140 = \\ _, empty, _ => empty\n\narr140 : Ty140 -> Ty140 -> Ty140\narr140 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon140 : Type\nCon140 = (Con140 : Type)\n ->(nil : Con140)\n ->(snoc : Con140 -> Ty140 -> Con140)\n -> Con140\n\nnil140 : Con140\nnil140 = \\ con, nil140, snoc => nil140\n\nsnoc140 : Con140 -> Ty140 -> Con140\nsnoc140 = \\ g, a, con, nil140, snoc140 => snoc140 (g con nil140 snoc140) a\n\nVar140 : Con140 -> Ty140 -> Type\nVar140 = \\ g, a =>\n (Var140 : Con140 -> Ty140 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var140 (snoc140 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var140 g a -> Var140 (snoc140 g b) a)\n -> Var140 g a\n\nvz140 : {g : _}-> {a : _} -> Var140 (snoc140 g a) a\nvz140 = \\ var, vz140, vs => vz140 _ _\n\nvs140 : {g : _} -> {B : _} -> {a : _} -> Var140 g a -> Var140 (snoc140 g B) a\nvs140 = \\ x, var, vz140, vs140 => vs140 _ _ _ (x var vz140 vs140)\n\nTm140 : Con140 -> Ty140 -> Type\nTm140 = \\ g, a =>\n (Tm140 : Con140 -> Ty140 -> Type)\n -> (var : (g : _) -> (a : _) -> Var140 g a -> Tm140 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm140 (snoc140 g a) B -> Tm140 g (arr140 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm140 g (arr140 a B) -> Tm140 g a -> Tm140 g B)\n -> Tm140 g a\n\nvar140 : {g : _} -> {a : _} -> Var140 g a -> Tm140 g a\nvar140 = \\ x, tm, var140, lam, app => var140 _ _ x\n\nlam140 : {g : _} -> {a : _} -> {B : _} -> Tm140 (snoc140 g a) B -> Tm140 g (arr140 a B)\nlam140 = \\ t, tm, var140, lam140, app => lam140 _ _ _ (t tm var140 lam140 app)\n\napp140 : {g:_}->{a:_}->{B:_} -> Tm140 g (arr140 a B) -> Tm140 g a -> Tm140 g B\napp140 = \\ t, u, tm, var140, lam140, app140 => app140 _ _ _ (t tm var140 lam140 app140) (u tm var140 lam140 app140)\n\nv0140 : {g:_}->{a:_} -> Tm140 (snoc140 g a) a\nv0140 = var140 vz140\n\nv1140 : {g:_}->{a:_}-> {B:_}-> Tm140 (snoc140 (snoc140 g a) B) a\nv1140 = var140 (vs140 vz140)\n\nv2140 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm140 (snoc140 (snoc140 (snoc140 g a) B) C) a\nv2140 = var140 (vs140 (vs140 vz140))\n\nv3140 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm140 (snoc140 (snoc140 (snoc140 (snoc140 g a) B) C) D) a\nv3140 = var140 (vs140 (vs140 (vs140 vz140)))\n\nv4140 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm140 (snoc140 (snoc140 (snoc140 (snoc140 (snoc140 g a) B) C) D) E) a\nv4140 = var140 (vs140 (vs140 (vs140 (vs140 vz140))))\n\ntest140 : {g:_}-> {a:_} -> Tm140 g (arr140 (arr140 a a) (arr140 a a))\ntest140 = lam140 (lam140 (app140 v1140 (app140 v1140 (app140 v1140 (app140 v1140 (app140 v1140 (app140 v1140 v0140)))))))\nTy141 : Type\nTy141 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty141 : Ty141\nempty141 = \\ _, empty, _ => empty\n\narr141 : Ty141 -> Ty141 -> Ty141\narr141 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon141 : Type\nCon141 = (Con141 : Type)\n ->(nil : Con141)\n ->(snoc : Con141 -> Ty141 -> Con141)\n -> Con141\n\nnil141 : Con141\nnil141 = \\ con, nil141, snoc => nil141\n\nsnoc141 : Con141 -> Ty141 -> Con141\nsnoc141 = \\ g, a, con, nil141, snoc141 => snoc141 (g con nil141 snoc141) a\n\nVar141 : Con141 -> Ty141 -> Type\nVar141 = \\ g, a =>\n (Var141 : Con141 -> Ty141 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var141 (snoc141 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var141 g a -> Var141 (snoc141 g b) a)\n -> Var141 g a\n\nvz141 : {g : _}-> {a : _} -> Var141 (snoc141 g a) a\nvz141 = \\ var, vz141, vs => vz141 _ _\n\nvs141 : {g : _} -> {B : _} -> {a : _} -> Var141 g a -> Var141 (snoc141 g B) a\nvs141 = \\ x, var, vz141, vs141 => vs141 _ _ _ (x var vz141 vs141)\n\nTm141 : Con141 -> Ty141 -> Type\nTm141 = \\ g, a =>\n (Tm141 : Con141 -> Ty141 -> Type)\n -> (var : (g : _) -> (a : _) -> Var141 g a -> Tm141 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm141 (snoc141 g a) B -> Tm141 g (arr141 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm141 g (arr141 a B) -> Tm141 g a -> Tm141 g B)\n -> Tm141 g a\n\nvar141 : {g : _} -> {a : _} -> Var141 g a -> Tm141 g a\nvar141 = \\ x, tm, var141, lam, app => var141 _ _ x\n\nlam141 : {g : _} -> {a : _} -> {B : _} -> Tm141 (snoc141 g a) B -> Tm141 g (arr141 a B)\nlam141 = \\ t, tm, var141, lam141, app => lam141 _ _ _ (t tm var141 lam141 app)\n\napp141 : {g:_}->{a:_}->{B:_} -> Tm141 g (arr141 a B) -> Tm141 g a -> Tm141 g B\napp141 = \\ t, u, tm, var141, lam141, app141 => app141 _ _ _ (t tm var141 lam141 app141) (u tm var141 lam141 app141)\n\nv0141 : {g:_}->{a:_} -> Tm141 (snoc141 g a) a\nv0141 = var141 vz141\n\nv1141 : {g:_}->{a:_}-> {B:_}-> Tm141 (snoc141 (snoc141 g a) B) a\nv1141 = var141 (vs141 vz141)\n\nv2141 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm141 (snoc141 (snoc141 (snoc141 g a) B) C) a\nv2141 = var141 (vs141 (vs141 vz141))\n\nv3141 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm141 (snoc141 (snoc141 (snoc141 (snoc141 g a) B) C) D) a\nv3141 = var141 (vs141 (vs141 (vs141 vz141)))\n\nv4141 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm141 (snoc141 (snoc141 (snoc141 (snoc141 (snoc141 g a) B) C) D) E) a\nv4141 = var141 (vs141 (vs141 (vs141 (vs141 vz141))))\n\ntest141 : {g:_}-> {a:_} -> Tm141 g (arr141 (arr141 a a) (arr141 a a))\ntest141 = lam141 (lam141 (app141 v1141 (app141 v1141 (app141 v1141 (app141 v1141 (app141 v1141 (app141 v1141 v0141)))))))\nTy142 : Type\nTy142 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty142 : Ty142\nempty142 = \\ _, empty, _ => empty\n\narr142 : Ty142 -> Ty142 -> Ty142\narr142 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon142 : Type\nCon142 = (Con142 : Type)\n ->(nil : Con142)\n ->(snoc : Con142 -> Ty142 -> Con142)\n -> Con142\n\nnil142 : Con142\nnil142 = \\ con, nil142, snoc => nil142\n\nsnoc142 : Con142 -> Ty142 -> Con142\nsnoc142 = \\ g, a, con, nil142, snoc142 => snoc142 (g con nil142 snoc142) a\n\nVar142 : Con142 -> Ty142 -> Type\nVar142 = \\ g, a =>\n (Var142 : Con142 -> Ty142 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var142 (snoc142 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var142 g a -> Var142 (snoc142 g b) a)\n -> Var142 g a\n\nvz142 : {g : _}-> {a : _} -> Var142 (snoc142 g a) a\nvz142 = \\ var, vz142, vs => vz142 _ _\n\nvs142 : {g : _} -> {B : _} -> {a : _} -> Var142 g a -> Var142 (snoc142 g B) a\nvs142 = \\ x, var, vz142, vs142 => vs142 _ _ _ (x var vz142 vs142)\n\nTm142 : Con142 -> Ty142 -> Type\nTm142 = \\ g, a =>\n (Tm142 : Con142 -> Ty142 -> Type)\n -> (var : (g : _) -> (a : _) -> Var142 g a -> Tm142 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm142 (snoc142 g a) B -> Tm142 g (arr142 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm142 g (arr142 a B) -> Tm142 g a -> Tm142 g B)\n -> Tm142 g a\n\nvar142 : {g : _} -> {a : _} -> Var142 g a -> Tm142 g a\nvar142 = \\ x, tm, var142, lam, app => var142 _ _ x\n\nlam142 : {g : _} -> {a : _} -> {B : _} -> Tm142 (snoc142 g a) B -> Tm142 g (arr142 a B)\nlam142 = \\ t, tm, var142, lam142, app => lam142 _ _ _ (t tm var142 lam142 app)\n\napp142 : {g:_}->{a:_}->{B:_} -> Tm142 g (arr142 a B) -> Tm142 g a -> Tm142 g B\napp142 = \\ t, u, tm, var142, lam142, app142 => app142 _ _ _ (t tm var142 lam142 app142) (u tm var142 lam142 app142)\n\nv0142 : {g:_}->{a:_} -> Tm142 (snoc142 g a) a\nv0142 = var142 vz142\n\nv1142 : {g:_}->{a:_}-> {B:_}-> Tm142 (snoc142 (snoc142 g a) B) a\nv1142 = var142 (vs142 vz142)\n\nv2142 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm142 (snoc142 (snoc142 (snoc142 g a) B) C) a\nv2142 = var142 (vs142 (vs142 vz142))\n\nv3142 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm142 (snoc142 (snoc142 (snoc142 (snoc142 g a) B) C) D) a\nv3142 = var142 (vs142 (vs142 (vs142 vz142)))\n\nv4142 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm142 (snoc142 (snoc142 (snoc142 (snoc142 (snoc142 g a) B) C) D) E) a\nv4142 = var142 (vs142 (vs142 (vs142 (vs142 vz142))))\n\ntest142 : {g:_}-> {a:_} -> Tm142 g (arr142 (arr142 a a) (arr142 a a))\ntest142 = lam142 (lam142 (app142 v1142 (app142 v1142 (app142 v1142 (app142 v1142 (app142 v1142 (app142 v1142 v0142)))))))\nTy143 : Type\nTy143 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty143 : Ty143\nempty143 = \\ _, empty, _ => empty\n\narr143 : Ty143 -> Ty143 -> Ty143\narr143 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon143 : Type\nCon143 = (Con143 : Type)\n ->(nil : Con143)\n ->(snoc : Con143 -> Ty143 -> Con143)\n -> Con143\n\nnil143 : Con143\nnil143 = \\ con, nil143, snoc => nil143\n\nsnoc143 : Con143 -> Ty143 -> Con143\nsnoc143 = \\ g, a, con, nil143, snoc143 => snoc143 (g con nil143 snoc143) a\n\nVar143 : Con143 -> Ty143 -> Type\nVar143 = \\ g, a =>\n (Var143 : Con143 -> Ty143 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var143 (snoc143 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var143 g a -> Var143 (snoc143 g b) a)\n -> Var143 g a\n\nvz143 : {g : _}-> {a : _} -> Var143 (snoc143 g a) a\nvz143 = \\ var, vz143, vs => vz143 _ _\n\nvs143 : {g : _} -> {B : _} -> {a : _} -> Var143 g a -> Var143 (snoc143 g B) a\nvs143 = \\ x, var, vz143, vs143 => vs143 _ _ _ (x var vz143 vs143)\n\nTm143 : Con143 -> Ty143 -> Type\nTm143 = \\ g, a =>\n (Tm143 : Con143 -> Ty143 -> Type)\n -> (var : (g : _) -> (a : _) -> Var143 g a -> Tm143 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm143 (snoc143 g a) B -> Tm143 g (arr143 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm143 g (arr143 a B) -> Tm143 g a -> Tm143 g B)\n -> Tm143 g a\n\nvar143 : {g : _} -> {a : _} -> Var143 g a -> Tm143 g a\nvar143 = \\ x, tm, var143, lam, app => var143 _ _ x\n\nlam143 : {g : _} -> {a : _} -> {B : _} -> Tm143 (snoc143 g a) B -> Tm143 g (arr143 a B)\nlam143 = \\ t, tm, var143, lam143, app => lam143 _ _ _ (t tm var143 lam143 app)\n\napp143 : {g:_}->{a:_}->{B:_} -> Tm143 g (arr143 a B) -> Tm143 g a -> Tm143 g B\napp143 = \\ t, u, tm, var143, lam143, app143 => app143 _ _ _ (t tm var143 lam143 app143) (u tm var143 lam143 app143)\n\nv0143 : {g:_}->{a:_} -> Tm143 (snoc143 g a) a\nv0143 = var143 vz143\n\nv1143 : {g:_}->{a:_}-> {B:_}-> Tm143 (snoc143 (snoc143 g a) B) a\nv1143 = var143 (vs143 vz143)\n\nv2143 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm143 (snoc143 (snoc143 (snoc143 g a) B) C) a\nv2143 = var143 (vs143 (vs143 vz143))\n\nv3143 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm143 (snoc143 (snoc143 (snoc143 (snoc143 g a) B) C) D) a\nv3143 = var143 (vs143 (vs143 (vs143 vz143)))\n\nv4143 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm143 (snoc143 (snoc143 (snoc143 (snoc143 (snoc143 g a) B) C) D) E) a\nv4143 = var143 (vs143 (vs143 (vs143 (vs143 vz143))))\n\ntest143 : {g:_}-> {a:_} -> Tm143 g (arr143 (arr143 a a) (arr143 a a))\ntest143 = lam143 (lam143 (app143 v1143 (app143 v1143 (app143 v1143 (app143 v1143 (app143 v1143 (app143 v1143 v0143)))))))\nTy144 : Type\nTy144 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty144 : Ty144\nempty144 = \\ _, empty, _ => empty\n\narr144 : Ty144 -> Ty144 -> Ty144\narr144 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon144 : Type\nCon144 = (Con144 : Type)\n ->(nil : Con144)\n ->(snoc : Con144 -> Ty144 -> Con144)\n -> Con144\n\nnil144 : Con144\nnil144 = \\ con, nil144, snoc => nil144\n\nsnoc144 : Con144 -> Ty144 -> Con144\nsnoc144 = \\ g, a, con, nil144, snoc144 => snoc144 (g con nil144 snoc144) a\n\nVar144 : Con144 -> Ty144 -> Type\nVar144 = \\ g, a =>\n (Var144 : Con144 -> Ty144 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var144 (snoc144 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var144 g a -> Var144 (snoc144 g b) a)\n -> Var144 g a\n\nvz144 : {g : _}-> {a : _} -> Var144 (snoc144 g a) a\nvz144 = \\ var, vz144, vs => vz144 _ _\n\nvs144 : {g : _} -> {B : _} -> {a : _} -> Var144 g a -> Var144 (snoc144 g B) a\nvs144 = \\ x, var, vz144, vs144 => vs144 _ _ _ (x var vz144 vs144)\n\nTm144 : Con144 -> Ty144 -> Type\nTm144 = \\ g, a =>\n (Tm144 : Con144 -> Ty144 -> Type)\n -> (var : (g : _) -> (a : _) -> Var144 g a -> Tm144 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm144 (snoc144 g a) B -> Tm144 g (arr144 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm144 g (arr144 a B) -> Tm144 g a -> Tm144 g B)\n -> Tm144 g a\n\nvar144 : {g : _} -> {a : _} -> Var144 g a -> Tm144 g a\nvar144 = \\ x, tm, var144, lam, app => var144 _ _ x\n\nlam144 : {g : _} -> {a : _} -> {B : _} -> Tm144 (snoc144 g a) B -> Tm144 g (arr144 a B)\nlam144 = \\ t, tm, var144, lam144, app => lam144 _ _ _ (t tm var144 lam144 app)\n\napp144 : {g:_}->{a:_}->{B:_} -> Tm144 g (arr144 a B) -> Tm144 g a -> Tm144 g B\napp144 = \\ t, u, tm, var144, lam144, app144 => app144 _ _ _ (t tm var144 lam144 app144) (u tm var144 lam144 app144)\n\nv0144 : {g:_}->{a:_} -> Tm144 (snoc144 g a) a\nv0144 = var144 vz144\n\nv1144 : {g:_}->{a:_}-> {B:_}-> Tm144 (snoc144 (snoc144 g a) B) a\nv1144 = var144 (vs144 vz144)\n\nv2144 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm144 (snoc144 (snoc144 (snoc144 g a) B) C) a\nv2144 = var144 (vs144 (vs144 vz144))\n\nv3144 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm144 (snoc144 (snoc144 (snoc144 (snoc144 g a) B) C) D) a\nv3144 = var144 (vs144 (vs144 (vs144 vz144)))\n\nv4144 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm144 (snoc144 (snoc144 (snoc144 (snoc144 (snoc144 g a) B) C) D) E) a\nv4144 = var144 (vs144 (vs144 (vs144 (vs144 vz144))))\n\ntest144 : {g:_}-> {a:_} -> Tm144 g (arr144 (arr144 a a) (arr144 a a))\ntest144 = lam144 (lam144 (app144 v1144 (app144 v1144 (app144 v1144 (app144 v1144 (app144 v1144 (app144 v1144 v0144)))))))\nTy145 : Type\nTy145 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty145 : Ty145\nempty145 = \\ _, empty, _ => empty\n\narr145 : Ty145 -> Ty145 -> Ty145\narr145 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon145 : Type\nCon145 = (Con145 : Type)\n ->(nil : Con145)\n ->(snoc : Con145 -> Ty145 -> Con145)\n -> Con145\n\nnil145 : Con145\nnil145 = \\ con, nil145, snoc => nil145\n\nsnoc145 : Con145 -> Ty145 -> Con145\nsnoc145 = \\ g, a, con, nil145, snoc145 => snoc145 (g con nil145 snoc145) a\n\nVar145 : Con145 -> Ty145 -> Type\nVar145 = \\ g, a =>\n (Var145 : Con145 -> Ty145 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var145 (snoc145 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var145 g a -> Var145 (snoc145 g b) a)\n -> Var145 g a\n\nvz145 : {g : _}-> {a : _} -> Var145 (snoc145 g a) a\nvz145 = \\ var, vz145, vs => vz145 _ _\n\nvs145 : {g : _} -> {B : _} -> {a : _} -> Var145 g a -> Var145 (snoc145 g B) a\nvs145 = \\ x, var, vz145, vs145 => vs145 _ _ _ (x var vz145 vs145)\n\nTm145 : Con145 -> Ty145 -> Type\nTm145 = \\ g, a =>\n (Tm145 : Con145 -> Ty145 -> Type)\n -> (var : (g : _) -> (a : _) -> Var145 g a -> Tm145 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm145 (snoc145 g a) B -> Tm145 g (arr145 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm145 g (arr145 a B) -> Tm145 g a -> Tm145 g B)\n -> Tm145 g a\n\nvar145 : {g : _} -> {a : _} -> Var145 g a -> Tm145 g a\nvar145 = \\ x, tm, var145, lam, app => var145 _ _ x\n\nlam145 : {g : _} -> {a : _} -> {B : _} -> Tm145 (snoc145 g a) B -> Tm145 g (arr145 a B)\nlam145 = \\ t, tm, var145, lam145, app => lam145 _ _ _ (t tm var145 lam145 app)\n\napp145 : {g:_}->{a:_}->{B:_} -> Tm145 g (arr145 a B) -> Tm145 g a -> Tm145 g B\napp145 = \\ t, u, tm, var145, lam145, app145 => app145 _ _ _ (t tm var145 lam145 app145) (u tm var145 lam145 app145)\n\nv0145 : {g:_}->{a:_} -> Tm145 (snoc145 g a) a\nv0145 = var145 vz145\n\nv1145 : {g:_}->{a:_}-> {B:_}-> Tm145 (snoc145 (snoc145 g a) B) a\nv1145 = var145 (vs145 vz145)\n\nv2145 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm145 (snoc145 (snoc145 (snoc145 g a) B) C) a\nv2145 = var145 (vs145 (vs145 vz145))\n\nv3145 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm145 (snoc145 (snoc145 (snoc145 (snoc145 g a) B) C) D) a\nv3145 = var145 (vs145 (vs145 (vs145 vz145)))\n\nv4145 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm145 (snoc145 (snoc145 (snoc145 (snoc145 (snoc145 g a) B) C) D) E) a\nv4145 = var145 (vs145 (vs145 (vs145 (vs145 vz145))))\n\ntest145 : {g:_}-> {a:_} -> Tm145 g (arr145 (arr145 a a) (arr145 a a))\ntest145 = lam145 (lam145 (app145 v1145 (app145 v1145 (app145 v1145 (app145 v1145 (app145 v1145 (app145 v1145 v0145)))))))\nTy146 : Type\nTy146 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty146 : Ty146\nempty146 = \\ _, empty, _ => empty\n\narr146 : Ty146 -> Ty146 -> Ty146\narr146 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon146 : Type\nCon146 = (Con146 : Type)\n ->(nil : Con146)\n ->(snoc : Con146 -> Ty146 -> Con146)\n -> Con146\n\nnil146 : Con146\nnil146 = \\ con, nil146, snoc => nil146\n\nsnoc146 : Con146 -> Ty146 -> Con146\nsnoc146 = \\ g, a, con, nil146, snoc146 => snoc146 (g con nil146 snoc146) a\n\nVar146 : Con146 -> Ty146 -> Type\nVar146 = \\ g, a =>\n (Var146 : Con146 -> Ty146 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var146 (snoc146 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var146 g a -> Var146 (snoc146 g b) a)\n -> Var146 g a\n\nvz146 : {g : _}-> {a : _} -> Var146 (snoc146 g a) a\nvz146 = \\ var, vz146, vs => vz146 _ _\n\nvs146 : {g : _} -> {B : _} -> {a : _} -> Var146 g a -> Var146 (snoc146 g B) a\nvs146 = \\ x, var, vz146, vs146 => vs146 _ _ _ (x var vz146 vs146)\n\nTm146 : Con146 -> Ty146 -> Type\nTm146 = \\ g, a =>\n (Tm146 : Con146 -> Ty146 -> Type)\n -> (var : (g : _) -> (a : _) -> Var146 g a -> Tm146 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm146 (snoc146 g a) B -> Tm146 g (arr146 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm146 g (arr146 a B) -> Tm146 g a -> Tm146 g B)\n -> Tm146 g a\n\nvar146 : {g : _} -> {a : _} -> Var146 g a -> Tm146 g a\nvar146 = \\ x, tm, var146, lam, app => var146 _ _ x\n\nlam146 : {g : _} -> {a : _} -> {B : _} -> Tm146 (snoc146 g a) B -> Tm146 g (arr146 a B)\nlam146 = \\ t, tm, var146, lam146, app => lam146 _ _ _ (t tm var146 lam146 app)\n\napp146 : {g:_}->{a:_}->{B:_} -> Tm146 g (arr146 a B) -> Tm146 g a -> Tm146 g B\napp146 = \\ t, u, tm, var146, lam146, app146 => app146 _ _ _ (t tm var146 lam146 app146) (u tm var146 lam146 app146)\n\nv0146 : {g:_}->{a:_} -> Tm146 (snoc146 g a) a\nv0146 = var146 vz146\n\nv1146 : {g:_}->{a:_}-> {B:_}-> Tm146 (snoc146 (snoc146 g a) B) a\nv1146 = var146 (vs146 vz146)\n\nv2146 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm146 (snoc146 (snoc146 (snoc146 g a) B) C) a\nv2146 = var146 (vs146 (vs146 vz146))\n\nv3146 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm146 (snoc146 (snoc146 (snoc146 (snoc146 g a) B) C) D) a\nv3146 = var146 (vs146 (vs146 (vs146 vz146)))\n\nv4146 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm146 (snoc146 (snoc146 (snoc146 (snoc146 (snoc146 g a) B) C) D) E) a\nv4146 = var146 (vs146 (vs146 (vs146 (vs146 vz146))))\n\ntest146 : {g:_}-> {a:_} -> Tm146 g (arr146 (arr146 a a) (arr146 a a))\ntest146 = lam146 (lam146 (app146 v1146 (app146 v1146 (app146 v1146 (app146 v1146 (app146 v1146 (app146 v1146 v0146)))))))\nTy147 : Type\nTy147 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty147 : Ty147\nempty147 = \\ _, empty, _ => empty\n\narr147 : Ty147 -> Ty147 -> Ty147\narr147 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon147 : Type\nCon147 = (Con147 : Type)\n ->(nil : Con147)\n ->(snoc : Con147 -> Ty147 -> Con147)\n -> Con147\n\nnil147 : Con147\nnil147 = \\ con, nil147, snoc => nil147\n\nsnoc147 : Con147 -> Ty147 -> Con147\nsnoc147 = \\ g, a, con, nil147, snoc147 => snoc147 (g con nil147 snoc147) a\n\nVar147 : Con147 -> Ty147 -> Type\nVar147 = \\ g, a =>\n (Var147 : Con147 -> Ty147 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var147 (snoc147 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var147 g a -> Var147 (snoc147 g b) a)\n -> Var147 g a\n\nvz147 : {g : _}-> {a : _} -> Var147 (snoc147 g a) a\nvz147 = \\ var, vz147, vs => vz147 _ _\n\nvs147 : {g : _} -> {B : _} -> {a : _} -> Var147 g a -> Var147 (snoc147 g B) a\nvs147 = \\ x, var, vz147, vs147 => vs147 _ _ _ (x var vz147 vs147)\n\nTm147 : Con147 -> Ty147 -> Type\nTm147 = \\ g, a =>\n (Tm147 : Con147 -> Ty147 -> Type)\n -> (var : (g : _) -> (a : _) -> Var147 g a -> Tm147 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm147 (snoc147 g a) B -> Tm147 g (arr147 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm147 g (arr147 a B) -> Tm147 g a -> Tm147 g B)\n -> Tm147 g a\n\nvar147 : {g : _} -> {a : _} -> Var147 g a -> Tm147 g a\nvar147 = \\ x, tm, var147, lam, app => var147 _ _ x\n\nlam147 : {g : _} -> {a : _} -> {B : _} -> Tm147 (snoc147 g a) B -> Tm147 g (arr147 a B)\nlam147 = \\ t, tm, var147, lam147, app => lam147 _ _ _ (t tm var147 lam147 app)\n\napp147 : {g:_}->{a:_}->{B:_} -> Tm147 g (arr147 a B) -> Tm147 g a -> Tm147 g B\napp147 = \\ t, u, tm, var147, lam147, app147 => app147 _ _ _ (t tm var147 lam147 app147) (u tm var147 lam147 app147)\n\nv0147 : {g:_}->{a:_} -> Tm147 (snoc147 g a) a\nv0147 = var147 vz147\n\nv1147 : {g:_}->{a:_}-> {B:_}-> Tm147 (snoc147 (snoc147 g a) B) a\nv1147 = var147 (vs147 vz147)\n\nv2147 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm147 (snoc147 (snoc147 (snoc147 g a) B) C) a\nv2147 = var147 (vs147 (vs147 vz147))\n\nv3147 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm147 (snoc147 (snoc147 (snoc147 (snoc147 g a) B) C) D) a\nv3147 = var147 (vs147 (vs147 (vs147 vz147)))\n\nv4147 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm147 (snoc147 (snoc147 (snoc147 (snoc147 (snoc147 g a) B) C) D) E) a\nv4147 = var147 (vs147 (vs147 (vs147 (vs147 vz147))))\n\ntest147 : {g:_}-> {a:_} -> Tm147 g (arr147 (arr147 a a) (arr147 a a))\ntest147 = lam147 (lam147 (app147 v1147 (app147 v1147 (app147 v1147 (app147 v1147 (app147 v1147 (app147 v1147 v0147)))))))\nTy148 : Type\nTy148 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty148 : Ty148\nempty148 = \\ _, empty, _ => empty\n\narr148 : Ty148 -> Ty148 -> Ty148\narr148 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon148 : Type\nCon148 = (Con148 : Type)\n ->(nil : Con148)\n ->(snoc : Con148 -> Ty148 -> Con148)\n -> Con148\n\nnil148 : Con148\nnil148 = \\ con, nil148, snoc => nil148\n\nsnoc148 : Con148 -> Ty148 -> Con148\nsnoc148 = \\ g, a, con, nil148, snoc148 => snoc148 (g con nil148 snoc148) a\n\nVar148 : Con148 -> Ty148 -> Type\nVar148 = \\ g, a =>\n (Var148 : Con148 -> Ty148 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var148 (snoc148 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var148 g a -> Var148 (snoc148 g b) a)\n -> Var148 g a\n\nvz148 : {g : _}-> {a : _} -> Var148 (snoc148 g a) a\nvz148 = \\ var, vz148, vs => vz148 _ _\n\nvs148 : {g : _} -> {B : _} -> {a : _} -> Var148 g a -> Var148 (snoc148 g B) a\nvs148 = \\ x, var, vz148, vs148 => vs148 _ _ _ (x var vz148 vs148)\n\nTm148 : Con148 -> Ty148 -> Type\nTm148 = \\ g, a =>\n (Tm148 : Con148 -> Ty148 -> Type)\n -> (var : (g : _) -> (a : _) -> Var148 g a -> Tm148 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm148 (snoc148 g a) B -> Tm148 g (arr148 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm148 g (arr148 a B) -> Tm148 g a -> Tm148 g B)\n -> Tm148 g a\n\nvar148 : {g : _} -> {a : _} -> Var148 g a -> Tm148 g a\nvar148 = \\ x, tm, var148, lam, app => var148 _ _ x\n\nlam148 : {g : _} -> {a : _} -> {B : _} -> Tm148 (snoc148 g a) B -> Tm148 g (arr148 a B)\nlam148 = \\ t, tm, var148, lam148, app => lam148 _ _ _ (t tm var148 lam148 app)\n\napp148 : {g:_}->{a:_}->{B:_} -> Tm148 g (arr148 a B) -> Tm148 g a -> Tm148 g B\napp148 = \\ t, u, tm, var148, lam148, app148 => app148 _ _ _ (t tm var148 lam148 app148) (u tm var148 lam148 app148)\n\nv0148 : {g:_}->{a:_} -> Tm148 (snoc148 g a) a\nv0148 = var148 vz148\n\nv1148 : {g:_}->{a:_}-> {B:_}-> Tm148 (snoc148 (snoc148 g a) B) a\nv1148 = var148 (vs148 vz148)\n\nv2148 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm148 (snoc148 (snoc148 (snoc148 g a) B) C) a\nv2148 = var148 (vs148 (vs148 vz148))\n\nv3148 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm148 (snoc148 (snoc148 (snoc148 (snoc148 g a) B) C) D) a\nv3148 = var148 (vs148 (vs148 (vs148 vz148)))\n\nv4148 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm148 (snoc148 (snoc148 (snoc148 (snoc148 (snoc148 g a) B) C) D) E) a\nv4148 = var148 (vs148 (vs148 (vs148 (vs148 vz148))))\n\ntest148 : {g:_}-> {a:_} -> Tm148 g (arr148 (arr148 a a) (arr148 a a))\ntest148 = lam148 (lam148 (app148 v1148 (app148 v1148 (app148 v1148 (app148 v1148 (app148 v1148 (app148 v1148 v0148)))))))\nTy149 : Type\nTy149 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty149 : Ty149\nempty149 = \\ _, empty, _ => empty\n\narr149 : Ty149 -> Ty149 -> Ty149\narr149 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon149 : Type\nCon149 = (Con149 : Type)\n ->(nil : Con149)\n ->(snoc : Con149 -> Ty149 -> Con149)\n -> Con149\n\nnil149 : Con149\nnil149 = \\ con, nil149, snoc => nil149\n\nsnoc149 : Con149 -> Ty149 -> Con149\nsnoc149 = \\ g, a, con, nil149, snoc149 => snoc149 (g con nil149 snoc149) a\n\nVar149 : Con149 -> Ty149 -> Type\nVar149 = \\ g, a =>\n (Var149 : Con149 -> Ty149 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var149 (snoc149 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var149 g a -> Var149 (snoc149 g b) a)\n -> Var149 g a\n\nvz149 : {g : _}-> {a : _} -> Var149 (snoc149 g a) a\nvz149 = \\ var, vz149, vs => vz149 _ _\n\nvs149 : {g : _} -> {B : _} -> {a : _} -> Var149 g a -> Var149 (snoc149 g B) a\nvs149 = \\ x, var, vz149, vs149 => vs149 _ _ _ (x var vz149 vs149)\n\nTm149 : Con149 -> Ty149 -> Type\nTm149 = \\ g, a =>\n (Tm149 : Con149 -> Ty149 -> Type)\n -> (var : (g : _) -> (a : _) -> Var149 g a -> Tm149 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm149 (snoc149 g a) B -> Tm149 g (arr149 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm149 g (arr149 a B) -> Tm149 g a -> Tm149 g B)\n -> Tm149 g a\n\nvar149 : {g : _} -> {a : _} -> Var149 g a -> Tm149 g a\nvar149 = \\ x, tm, var149, lam, app => var149 _ _ x\n\nlam149 : {g : _} -> {a : _} -> {B : _} -> Tm149 (snoc149 g a) B -> Tm149 g (arr149 a B)\nlam149 = \\ t, tm, var149, lam149, app => lam149 _ _ _ (t tm var149 lam149 app)\n\napp149 : {g:_}->{a:_}->{B:_} -> Tm149 g (arr149 a B) -> Tm149 g a -> Tm149 g B\napp149 = \\ t, u, tm, var149, lam149, app149 => app149 _ _ _ (t tm var149 lam149 app149) (u tm var149 lam149 app149)\n\nv0149 : {g:_}->{a:_} -> Tm149 (snoc149 g a) a\nv0149 = var149 vz149\n\nv1149 : {g:_}->{a:_}-> {B:_}-> Tm149 (snoc149 (snoc149 g a) B) a\nv1149 = var149 (vs149 vz149)\n\nv2149 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm149 (snoc149 (snoc149 (snoc149 g a) B) C) a\nv2149 = var149 (vs149 (vs149 vz149))\n\nv3149 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm149 (snoc149 (snoc149 (snoc149 (snoc149 g a) B) C) D) a\nv3149 = var149 (vs149 (vs149 (vs149 vz149)))\n\nv4149 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm149 (snoc149 (snoc149 (snoc149 (snoc149 (snoc149 g a) B) C) D) E) a\nv4149 = var149 (vs149 (vs149 (vs149 (vs149 vz149))))\n\ntest149 : {g:_}-> {a:_} -> Tm149 g (arr149 (arr149 a a) (arr149 a a))\ntest149 = lam149 (lam149 (app149 v1149 (app149 v1149 (app149 v1149 (app149 v1149 (app149 v1149 (app149 v1149 v0149)))))))\nTy150 : Type\nTy150 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty150 : Ty150\nempty150 = \\ _, empty, _ => empty\n\narr150 : Ty150 -> Ty150 -> Ty150\narr150 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon150 : Type\nCon150 = (Con150 : Type)\n ->(nil : Con150)\n ->(snoc : Con150 -> Ty150 -> Con150)\n -> Con150\n\nnil150 : Con150\nnil150 = \\ con, nil150, snoc => nil150\n\nsnoc150 : Con150 -> Ty150 -> Con150\nsnoc150 = \\ g, a, con, nil150, snoc150 => snoc150 (g con nil150 snoc150) a\n\nVar150 : Con150 -> Ty150 -> Type\nVar150 = \\ g, a =>\n (Var150 : Con150 -> Ty150 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var150 (snoc150 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var150 g a -> Var150 (snoc150 g b) a)\n -> Var150 g a\n\nvz150 : {g : _}-> {a : _} -> Var150 (snoc150 g a) a\nvz150 = \\ var, vz150, vs => vz150 _ _\n\nvs150 : {g : _} -> {B : _} -> {a : _} -> Var150 g a -> Var150 (snoc150 g B) a\nvs150 = \\ x, var, vz150, vs150 => vs150 _ _ _ (x var vz150 vs150)\n\nTm150 : Con150 -> Ty150 -> Type\nTm150 = \\ g, a =>\n (Tm150 : Con150 -> Ty150 -> Type)\n -> (var : (g : _) -> (a : _) -> Var150 g a -> Tm150 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm150 (snoc150 g a) B -> Tm150 g (arr150 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm150 g (arr150 a B) -> Tm150 g a -> Tm150 g B)\n -> Tm150 g a\n\nvar150 : {g : _} -> {a : _} -> Var150 g a -> Tm150 g a\nvar150 = \\ x, tm, var150, lam, app => var150 _ _ x\n\nlam150 : {g : _} -> {a : _} -> {B : _} -> Tm150 (snoc150 g a) B -> Tm150 g (arr150 a B)\nlam150 = \\ t, tm, var150, lam150, app => lam150 _ _ _ (t tm var150 lam150 app)\n\napp150 : {g:_}->{a:_}->{B:_} -> Tm150 g (arr150 a B) -> Tm150 g a -> Tm150 g B\napp150 = \\ t, u, tm, var150, lam150, app150 => app150 _ _ _ (t tm var150 lam150 app150) (u tm var150 lam150 app150)\n\nv0150 : {g:_}->{a:_} -> Tm150 (snoc150 g a) a\nv0150 = var150 vz150\n\nv1150 : {g:_}->{a:_}-> {B:_}-> Tm150 (snoc150 (snoc150 g a) B) a\nv1150 = var150 (vs150 vz150)\n\nv2150 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm150 (snoc150 (snoc150 (snoc150 g a) B) C) a\nv2150 = var150 (vs150 (vs150 vz150))\n\nv3150 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm150 (snoc150 (snoc150 (snoc150 (snoc150 g a) B) C) D) a\nv3150 = var150 (vs150 (vs150 (vs150 vz150)))\n\nv4150 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm150 (snoc150 (snoc150 (snoc150 (snoc150 (snoc150 g a) B) C) D) E) a\nv4150 = var150 (vs150 (vs150 (vs150 (vs150 vz150))))\n\ntest150 : {g:_}-> {a:_} -> Tm150 g (arr150 (arr150 a a) (arr150 a a))\ntest150 = lam150 (lam150 (app150 v1150 (app150 v1150 (app150 v1150 (app150 v1150 (app150 v1150 (app150 v1150 v0150)))))))\nTy151 : Type\nTy151 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty151 : Ty151\nempty151 = \\ _, empty, _ => empty\n\narr151 : Ty151 -> Ty151 -> Ty151\narr151 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon151 : Type\nCon151 = (Con151 : Type)\n ->(nil : Con151)\n ->(snoc : Con151 -> Ty151 -> Con151)\n -> Con151\n\nnil151 : Con151\nnil151 = \\ con, nil151, snoc => nil151\n\nsnoc151 : Con151 -> Ty151 -> Con151\nsnoc151 = \\ g, a, con, nil151, snoc151 => snoc151 (g con nil151 snoc151) a\n\nVar151 : Con151 -> Ty151 -> Type\nVar151 = \\ g, a =>\n (Var151 : Con151 -> Ty151 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var151 (snoc151 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var151 g a -> Var151 (snoc151 g b) a)\n -> Var151 g a\n\nvz151 : {g : _}-> {a : _} -> Var151 (snoc151 g a) a\nvz151 = \\ var, vz151, vs => vz151 _ _\n\nvs151 : {g : _} -> {B : _} -> {a : _} -> Var151 g a -> Var151 (snoc151 g B) a\nvs151 = \\ x, var, vz151, vs151 => vs151 _ _ _ (x var vz151 vs151)\n\nTm151 : Con151 -> Ty151 -> Type\nTm151 = \\ g, a =>\n (Tm151 : Con151 -> Ty151 -> Type)\n -> (var : (g : _) -> (a : _) -> Var151 g a -> Tm151 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm151 (snoc151 g a) B -> Tm151 g (arr151 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm151 g (arr151 a B) -> Tm151 g a -> Tm151 g B)\n -> Tm151 g a\n\nvar151 : {g : _} -> {a : _} -> Var151 g a -> Tm151 g a\nvar151 = \\ x, tm, var151, lam, app => var151 _ _ x\n\nlam151 : {g : _} -> {a : _} -> {B : _} -> Tm151 (snoc151 g a) B -> Tm151 g (arr151 a B)\nlam151 = \\ t, tm, var151, lam151, app => lam151 _ _ _ (t tm var151 lam151 app)\n\napp151 : {g:_}->{a:_}->{B:_} -> Tm151 g (arr151 a B) -> Tm151 g a -> Tm151 g B\napp151 = \\ t, u, tm, var151, lam151, app151 => app151 _ _ _ (t tm var151 lam151 app151) (u tm var151 lam151 app151)\n\nv0151 : {g:_}->{a:_} -> Tm151 (snoc151 g a) a\nv0151 = var151 vz151\n\nv1151 : {g:_}->{a:_}-> {B:_}-> Tm151 (snoc151 (snoc151 g a) B) a\nv1151 = var151 (vs151 vz151)\n\nv2151 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm151 (snoc151 (snoc151 (snoc151 g a) B) C) a\nv2151 = var151 (vs151 (vs151 vz151))\n\nv3151 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm151 (snoc151 (snoc151 (snoc151 (snoc151 g a) B) C) D) a\nv3151 = var151 (vs151 (vs151 (vs151 vz151)))\n\nv4151 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm151 (snoc151 (snoc151 (snoc151 (snoc151 (snoc151 g a) B) C) D) E) a\nv4151 = var151 (vs151 (vs151 (vs151 (vs151 vz151))))\n\ntest151 : {g:_}-> {a:_} -> Tm151 g (arr151 (arr151 a a) (arr151 a a))\ntest151 = lam151 (lam151 (app151 v1151 (app151 v1151 (app151 v1151 (app151 v1151 (app151 v1151 (app151 v1151 v0151)))))))\nTy152 : Type\nTy152 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty152 : Ty152\nempty152 = \\ _, empty, _ => empty\n\narr152 : Ty152 -> Ty152 -> Ty152\narr152 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon152 : Type\nCon152 = (Con152 : Type)\n ->(nil : Con152)\n ->(snoc : Con152 -> Ty152 -> Con152)\n -> Con152\n\nnil152 : Con152\nnil152 = \\ con, nil152, snoc => nil152\n\nsnoc152 : Con152 -> Ty152 -> Con152\nsnoc152 = \\ g, a, con, nil152, snoc152 => snoc152 (g con nil152 snoc152) a\n\nVar152 : Con152 -> Ty152 -> Type\nVar152 = \\ g, a =>\n (Var152 : Con152 -> Ty152 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var152 (snoc152 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var152 g a -> Var152 (snoc152 g b) a)\n -> Var152 g a\n\nvz152 : {g : _}-> {a : _} -> Var152 (snoc152 g a) a\nvz152 = \\ var, vz152, vs => vz152 _ _\n\nvs152 : {g : _} -> {B : _} -> {a : _} -> Var152 g a -> Var152 (snoc152 g B) a\nvs152 = \\ x, var, vz152, vs152 => vs152 _ _ _ (x var vz152 vs152)\n\nTm152 : Con152 -> Ty152 -> Type\nTm152 = \\ g, a =>\n (Tm152 : Con152 -> Ty152 -> Type)\n -> (var : (g : _) -> (a : _) -> Var152 g a -> Tm152 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm152 (snoc152 g a) B -> Tm152 g (arr152 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm152 g (arr152 a B) -> Tm152 g a -> Tm152 g B)\n -> Tm152 g a\n\nvar152 : {g : _} -> {a : _} -> Var152 g a -> Tm152 g a\nvar152 = \\ x, tm, var152, lam, app => var152 _ _ x\n\nlam152 : {g : _} -> {a : _} -> {B : _} -> Tm152 (snoc152 g a) B -> Tm152 g (arr152 a B)\nlam152 = \\ t, tm, var152, lam152, app => lam152 _ _ _ (t tm var152 lam152 app)\n\napp152 : {g:_}->{a:_}->{B:_} -> Tm152 g (arr152 a B) -> Tm152 g a -> Tm152 g B\napp152 = \\ t, u, tm, var152, lam152, app152 => app152 _ _ _ (t tm var152 lam152 app152) (u tm var152 lam152 app152)\n\nv0152 : {g:_}->{a:_} -> Tm152 (snoc152 g a) a\nv0152 = var152 vz152\n\nv1152 : {g:_}->{a:_}-> {B:_}-> Tm152 (snoc152 (snoc152 g a) B) a\nv1152 = var152 (vs152 vz152)\n\nv2152 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm152 (snoc152 (snoc152 (snoc152 g a) B) C) a\nv2152 = var152 (vs152 (vs152 vz152))\n\nv3152 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm152 (snoc152 (snoc152 (snoc152 (snoc152 g a) B) C) D) a\nv3152 = var152 (vs152 (vs152 (vs152 vz152)))\n\nv4152 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm152 (snoc152 (snoc152 (snoc152 (snoc152 (snoc152 g a) B) C) D) E) a\nv4152 = var152 (vs152 (vs152 (vs152 (vs152 vz152))))\n\ntest152 : {g:_}-> {a:_} -> Tm152 g (arr152 (arr152 a a) (arr152 a a))\ntest152 = lam152 (lam152 (app152 v1152 (app152 v1152 (app152 v1152 (app152 v1152 (app152 v1152 (app152 v1152 v0152)))))))\nTy153 : Type\nTy153 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty153 : Ty153\nempty153 = \\ _, empty, _ => empty\n\narr153 : Ty153 -> Ty153 -> Ty153\narr153 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon153 : Type\nCon153 = (Con153 : Type)\n ->(nil : Con153)\n ->(snoc : Con153 -> Ty153 -> Con153)\n -> Con153\n\nnil153 : Con153\nnil153 = \\ con, nil153, snoc => nil153\n\nsnoc153 : Con153 -> Ty153 -> Con153\nsnoc153 = \\ g, a, con, nil153, snoc153 => snoc153 (g con nil153 snoc153) a\n\nVar153 : Con153 -> Ty153 -> Type\nVar153 = \\ g, a =>\n (Var153 : Con153 -> Ty153 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var153 (snoc153 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var153 g a -> Var153 (snoc153 g b) a)\n -> Var153 g a\n\nvz153 : {g : _}-> {a : _} -> Var153 (snoc153 g a) a\nvz153 = \\ var, vz153, vs => vz153 _ _\n\nvs153 : {g : _} -> {B : _} -> {a : _} -> Var153 g a -> Var153 (snoc153 g B) a\nvs153 = \\ x, var, vz153, vs153 => vs153 _ _ _ (x var vz153 vs153)\n\nTm153 : Con153 -> Ty153 -> Type\nTm153 = \\ g, a =>\n (Tm153 : Con153 -> Ty153 -> Type)\n -> (var : (g : _) -> (a : _) -> Var153 g a -> Tm153 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm153 (snoc153 g a) B -> Tm153 g (arr153 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm153 g (arr153 a B) -> Tm153 g a -> Tm153 g B)\n -> Tm153 g a\n\nvar153 : {g : _} -> {a : _} -> Var153 g a -> Tm153 g a\nvar153 = \\ x, tm, var153, lam, app => var153 _ _ x\n\nlam153 : {g : _} -> {a : _} -> {B : _} -> Tm153 (snoc153 g a) B -> Tm153 g (arr153 a B)\nlam153 = \\ t, tm, var153, lam153, app => lam153 _ _ _ (t tm var153 lam153 app)\n\napp153 : {g:_}->{a:_}->{B:_} -> Tm153 g (arr153 a B) -> Tm153 g a -> Tm153 g B\napp153 = \\ t, u, tm, var153, lam153, app153 => app153 _ _ _ (t tm var153 lam153 app153) (u tm var153 lam153 app153)\n\nv0153 : {g:_}->{a:_} -> Tm153 (snoc153 g a) a\nv0153 = var153 vz153\n\nv1153 : {g:_}->{a:_}-> {B:_}-> Tm153 (snoc153 (snoc153 g a) B) a\nv1153 = var153 (vs153 vz153)\n\nv2153 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm153 (snoc153 (snoc153 (snoc153 g a) B) C) a\nv2153 = var153 (vs153 (vs153 vz153))\n\nv3153 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm153 (snoc153 (snoc153 (snoc153 (snoc153 g a) B) C) D) a\nv3153 = var153 (vs153 (vs153 (vs153 vz153)))\n\nv4153 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm153 (snoc153 (snoc153 (snoc153 (snoc153 (snoc153 g a) B) C) D) E) a\nv4153 = var153 (vs153 (vs153 (vs153 (vs153 vz153))))\n\ntest153 : {g:_}-> {a:_} -> Tm153 g (arr153 (arr153 a a) (arr153 a a))\ntest153 = lam153 (lam153 (app153 v1153 (app153 v1153 (app153 v1153 (app153 v1153 (app153 v1153 (app153 v1153 v0153)))))))\nTy154 : Type\nTy154 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty154 : Ty154\nempty154 = \\ _, empty, _ => empty\n\narr154 : Ty154 -> Ty154 -> Ty154\narr154 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon154 : Type\nCon154 = (Con154 : Type)\n ->(nil : Con154)\n ->(snoc : Con154 -> Ty154 -> Con154)\n -> Con154\n\nnil154 : Con154\nnil154 = \\ con, nil154, snoc => nil154\n\nsnoc154 : Con154 -> Ty154 -> Con154\nsnoc154 = \\ g, a, con, nil154, snoc154 => snoc154 (g con nil154 snoc154) a\n\nVar154 : Con154 -> Ty154 -> Type\nVar154 = \\ g, a =>\n (Var154 : Con154 -> Ty154 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var154 (snoc154 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var154 g a -> Var154 (snoc154 g b) a)\n -> Var154 g a\n\nvz154 : {g : _}-> {a : _} -> Var154 (snoc154 g a) a\nvz154 = \\ var, vz154, vs => vz154 _ _\n\nvs154 : {g : _} -> {B : _} -> {a : _} -> Var154 g a -> Var154 (snoc154 g B) a\nvs154 = \\ x, var, vz154, vs154 => vs154 _ _ _ (x var vz154 vs154)\n\nTm154 : Con154 -> Ty154 -> Type\nTm154 = \\ g, a =>\n (Tm154 : Con154 -> Ty154 -> Type)\n -> (var : (g : _) -> (a : _) -> Var154 g a -> Tm154 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm154 (snoc154 g a) B -> Tm154 g (arr154 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm154 g (arr154 a B) -> Tm154 g a -> Tm154 g B)\n -> Tm154 g a\n\nvar154 : {g : _} -> {a : _} -> Var154 g a -> Tm154 g a\nvar154 = \\ x, tm, var154, lam, app => var154 _ _ x\n\nlam154 : {g : _} -> {a : _} -> {B : _} -> Tm154 (snoc154 g a) B -> Tm154 g (arr154 a B)\nlam154 = \\ t, tm, var154, lam154, app => lam154 _ _ _ (t tm var154 lam154 app)\n\napp154 : {g:_}->{a:_}->{B:_} -> Tm154 g (arr154 a B) -> Tm154 g a -> Tm154 g B\napp154 = \\ t, u, tm, var154, lam154, app154 => app154 _ _ _ (t tm var154 lam154 app154) (u tm var154 lam154 app154)\n\nv0154 : {g:_}->{a:_} -> Tm154 (snoc154 g a) a\nv0154 = var154 vz154\n\nv1154 : {g:_}->{a:_}-> {B:_}-> Tm154 (snoc154 (snoc154 g a) B) a\nv1154 = var154 (vs154 vz154)\n\nv2154 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm154 (snoc154 (snoc154 (snoc154 g a) B) C) a\nv2154 = var154 (vs154 (vs154 vz154))\n\nv3154 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm154 (snoc154 (snoc154 (snoc154 (snoc154 g a) B) C) D) a\nv3154 = var154 (vs154 (vs154 (vs154 vz154)))\n\nv4154 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm154 (snoc154 (snoc154 (snoc154 (snoc154 (snoc154 g a) B) C) D) E) a\nv4154 = var154 (vs154 (vs154 (vs154 (vs154 vz154))))\n\ntest154 : {g:_}-> {a:_} -> Tm154 g (arr154 (arr154 a a) (arr154 a a))\ntest154 = lam154 (lam154 (app154 v1154 (app154 v1154 (app154 v1154 (app154 v1154 (app154 v1154 (app154 v1154 v0154)))))))\nTy155 : Type\nTy155 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty155 : Ty155\nempty155 = \\ _, empty, _ => empty\n\narr155 : Ty155 -> Ty155 -> Ty155\narr155 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon155 : Type\nCon155 = (Con155 : Type)\n ->(nil : Con155)\n ->(snoc : Con155 -> Ty155 -> Con155)\n -> Con155\n\nnil155 : Con155\nnil155 = \\ con, nil155, snoc => nil155\n\nsnoc155 : Con155 -> Ty155 -> Con155\nsnoc155 = \\ g, a, con, nil155, snoc155 => snoc155 (g con nil155 snoc155) a\n\nVar155 : Con155 -> Ty155 -> Type\nVar155 = \\ g, a =>\n (Var155 : Con155 -> Ty155 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var155 (snoc155 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var155 g a -> Var155 (snoc155 g b) a)\n -> Var155 g a\n\nvz155 : {g : _}-> {a : _} -> Var155 (snoc155 g a) a\nvz155 = \\ var, vz155, vs => vz155 _ _\n\nvs155 : {g : _} -> {B : _} -> {a : _} -> Var155 g a -> Var155 (snoc155 g B) a\nvs155 = \\ x, var, vz155, vs155 => vs155 _ _ _ (x var vz155 vs155)\n\nTm155 : Con155 -> Ty155 -> Type\nTm155 = \\ g, a =>\n (Tm155 : Con155 -> Ty155 -> Type)\n -> (var : (g : _) -> (a : _) -> Var155 g a -> Tm155 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm155 (snoc155 g a) B -> Tm155 g (arr155 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm155 g (arr155 a B) -> Tm155 g a -> Tm155 g B)\n -> Tm155 g a\n\nvar155 : {g : _} -> {a : _} -> Var155 g a -> Tm155 g a\nvar155 = \\ x, tm, var155, lam, app => var155 _ _ x\n\nlam155 : {g : _} -> {a : _} -> {B : _} -> Tm155 (snoc155 g a) B -> Tm155 g (arr155 a B)\nlam155 = \\ t, tm, var155, lam155, app => lam155 _ _ _ (t tm var155 lam155 app)\n\napp155 : {g:_}->{a:_}->{B:_} -> Tm155 g (arr155 a B) -> Tm155 g a -> Tm155 g B\napp155 = \\ t, u, tm, var155, lam155, app155 => app155 _ _ _ (t tm var155 lam155 app155) (u tm var155 lam155 app155)\n\nv0155 : {g:_}->{a:_} -> Tm155 (snoc155 g a) a\nv0155 = var155 vz155\n\nv1155 : {g:_}->{a:_}-> {B:_}-> Tm155 (snoc155 (snoc155 g a) B) a\nv1155 = var155 (vs155 vz155)\n\nv2155 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm155 (snoc155 (snoc155 (snoc155 g a) B) C) a\nv2155 = var155 (vs155 (vs155 vz155))\n\nv3155 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm155 (snoc155 (snoc155 (snoc155 (snoc155 g a) B) C) D) a\nv3155 = var155 (vs155 (vs155 (vs155 vz155)))\n\nv4155 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm155 (snoc155 (snoc155 (snoc155 (snoc155 (snoc155 g a) B) C) D) E) a\nv4155 = var155 (vs155 (vs155 (vs155 (vs155 vz155))))\n\ntest155 : {g:_}-> {a:_} -> Tm155 g (arr155 (arr155 a a) (arr155 a a))\ntest155 = lam155 (lam155 (app155 v1155 (app155 v1155 (app155 v1155 (app155 v1155 (app155 v1155 (app155 v1155 v0155)))))))\nTy156 : Type\nTy156 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty156 : Ty156\nempty156 = \\ _, empty, _ => empty\n\narr156 : Ty156 -> Ty156 -> Ty156\narr156 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon156 : Type\nCon156 = (Con156 : Type)\n ->(nil : Con156)\n ->(snoc : Con156 -> Ty156 -> Con156)\n -> Con156\n\nnil156 : Con156\nnil156 = \\ con, nil156, snoc => nil156\n\nsnoc156 : Con156 -> Ty156 -> Con156\nsnoc156 = \\ g, a, con, nil156, snoc156 => snoc156 (g con nil156 snoc156) a\n\nVar156 : Con156 -> Ty156 -> Type\nVar156 = \\ g, a =>\n (Var156 : Con156 -> Ty156 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var156 (snoc156 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var156 g a -> Var156 (snoc156 g b) a)\n -> Var156 g a\n\nvz156 : {g : _}-> {a : _} -> Var156 (snoc156 g a) a\nvz156 = \\ var, vz156, vs => vz156 _ _\n\nvs156 : {g : _} -> {B : _} -> {a : _} -> Var156 g a -> Var156 (snoc156 g B) a\nvs156 = \\ x, var, vz156, vs156 => vs156 _ _ _ (x var vz156 vs156)\n\nTm156 : Con156 -> Ty156 -> Type\nTm156 = \\ g, a =>\n (Tm156 : Con156 -> Ty156 -> Type)\n -> (var : (g : _) -> (a : _) -> Var156 g a -> Tm156 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm156 (snoc156 g a) B -> Tm156 g (arr156 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm156 g (arr156 a B) -> Tm156 g a -> Tm156 g B)\n -> Tm156 g a\n\nvar156 : {g : _} -> {a : _} -> Var156 g a -> Tm156 g a\nvar156 = \\ x, tm, var156, lam, app => var156 _ _ x\n\nlam156 : {g : _} -> {a : _} -> {B : _} -> Tm156 (snoc156 g a) B -> Tm156 g (arr156 a B)\nlam156 = \\ t, tm, var156, lam156, app => lam156 _ _ _ (t tm var156 lam156 app)\n\napp156 : {g:_}->{a:_}->{B:_} -> Tm156 g (arr156 a B) -> Tm156 g a -> Tm156 g B\napp156 = \\ t, u, tm, var156, lam156, app156 => app156 _ _ _ (t tm var156 lam156 app156) (u tm var156 lam156 app156)\n\nv0156 : {g:_}->{a:_} -> Tm156 (snoc156 g a) a\nv0156 = var156 vz156\n\nv1156 : {g:_}->{a:_}-> {B:_}-> Tm156 (snoc156 (snoc156 g a) B) a\nv1156 = var156 (vs156 vz156)\n\nv2156 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm156 (snoc156 (snoc156 (snoc156 g a) B) C) a\nv2156 = var156 (vs156 (vs156 vz156))\n\nv3156 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm156 (snoc156 (snoc156 (snoc156 (snoc156 g a) B) C) D) a\nv3156 = var156 (vs156 (vs156 (vs156 vz156)))\n\nv4156 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm156 (snoc156 (snoc156 (snoc156 (snoc156 (snoc156 g a) B) C) D) E) a\nv4156 = var156 (vs156 (vs156 (vs156 (vs156 vz156))))\n\ntest156 : {g:_}-> {a:_} -> Tm156 g (arr156 (arr156 a a) (arr156 a a))\ntest156 = lam156 (lam156 (app156 v1156 (app156 v1156 (app156 v1156 (app156 v1156 (app156 v1156 (app156 v1156 v0156)))))))\nTy157 : Type\nTy157 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty157 : Ty157\nempty157 = \\ _, empty, _ => empty\n\narr157 : Ty157 -> Ty157 -> Ty157\narr157 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon157 : Type\nCon157 = (Con157 : Type)\n ->(nil : Con157)\n ->(snoc : Con157 -> Ty157 -> Con157)\n -> Con157\n\nnil157 : Con157\nnil157 = \\ con, nil157, snoc => nil157\n\nsnoc157 : Con157 -> Ty157 -> Con157\nsnoc157 = \\ g, a, con, nil157, snoc157 => snoc157 (g con nil157 snoc157) a\n\nVar157 : Con157 -> Ty157 -> Type\nVar157 = \\ g, a =>\n (Var157 : Con157 -> Ty157 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var157 (snoc157 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var157 g a -> Var157 (snoc157 g b) a)\n -> Var157 g a\n\nvz157 : {g : _}-> {a : _} -> Var157 (snoc157 g a) a\nvz157 = \\ var, vz157, vs => vz157 _ _\n\nvs157 : {g : _} -> {B : _} -> {a : _} -> Var157 g a -> Var157 (snoc157 g B) a\nvs157 = \\ x, var, vz157, vs157 => vs157 _ _ _ (x var vz157 vs157)\n\nTm157 : Con157 -> Ty157 -> Type\nTm157 = \\ g, a =>\n (Tm157 : Con157 -> Ty157 -> Type)\n -> (var : (g : _) -> (a : _) -> Var157 g a -> Tm157 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm157 (snoc157 g a) B -> Tm157 g (arr157 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm157 g (arr157 a B) -> Tm157 g a -> Tm157 g B)\n -> Tm157 g a\n\nvar157 : {g : _} -> {a : _} -> Var157 g a -> Tm157 g a\nvar157 = \\ x, tm, var157, lam, app => var157 _ _ x\n\nlam157 : {g : _} -> {a : _} -> {B : _} -> Tm157 (snoc157 g a) B -> Tm157 g (arr157 a B)\nlam157 = \\ t, tm, var157, lam157, app => lam157 _ _ _ (t tm var157 lam157 app)\n\napp157 : {g:_}->{a:_}->{B:_} -> Tm157 g (arr157 a B) -> Tm157 g a -> Tm157 g B\napp157 = \\ t, u, tm, var157, lam157, app157 => app157 _ _ _ (t tm var157 lam157 app157) (u tm var157 lam157 app157)\n\nv0157 : {g:_}->{a:_} -> Tm157 (snoc157 g a) a\nv0157 = var157 vz157\n\nv1157 : {g:_}->{a:_}-> {B:_}-> Tm157 (snoc157 (snoc157 g a) B) a\nv1157 = var157 (vs157 vz157)\n\nv2157 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm157 (snoc157 (snoc157 (snoc157 g a) B) C) a\nv2157 = var157 (vs157 (vs157 vz157))\n\nv3157 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm157 (snoc157 (snoc157 (snoc157 (snoc157 g a) B) C) D) a\nv3157 = var157 (vs157 (vs157 (vs157 vz157)))\n\nv4157 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm157 (snoc157 (snoc157 (snoc157 (snoc157 (snoc157 g a) B) C) D) E) a\nv4157 = var157 (vs157 (vs157 (vs157 (vs157 vz157))))\n\ntest157 : {g:_}-> {a:_} -> Tm157 g (arr157 (arr157 a a) (arr157 a a))\ntest157 = lam157 (lam157 (app157 v1157 (app157 v1157 (app157 v1157 (app157 v1157 (app157 v1157 (app157 v1157 v0157)))))))\nTy158 : Type\nTy158 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty158 : Ty158\nempty158 = \\ _, empty, _ => empty\n\narr158 : Ty158 -> Ty158 -> Ty158\narr158 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon158 : Type\nCon158 = (Con158 : Type)\n ->(nil : Con158)\n ->(snoc : Con158 -> Ty158 -> Con158)\n -> Con158\n\nnil158 : Con158\nnil158 = \\ con, nil158, snoc => nil158\n\nsnoc158 : Con158 -> Ty158 -> Con158\nsnoc158 = \\ g, a, con, nil158, snoc158 => snoc158 (g con nil158 snoc158) a\n\nVar158 : Con158 -> Ty158 -> Type\nVar158 = \\ g, a =>\n (Var158 : Con158 -> Ty158 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var158 (snoc158 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var158 g a -> Var158 (snoc158 g b) a)\n -> Var158 g a\n\nvz158 : {g : _}-> {a : _} -> Var158 (snoc158 g a) a\nvz158 = \\ var, vz158, vs => vz158 _ _\n\nvs158 : {g : _} -> {B : _} -> {a : _} -> Var158 g a -> Var158 (snoc158 g B) a\nvs158 = \\ x, var, vz158, vs158 => vs158 _ _ _ (x var vz158 vs158)\n\nTm158 : Con158 -> Ty158 -> Type\nTm158 = \\ g, a =>\n (Tm158 : Con158 -> Ty158 -> Type)\n -> (var : (g : _) -> (a : _) -> Var158 g a -> Tm158 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm158 (snoc158 g a) B -> Tm158 g (arr158 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm158 g (arr158 a B) -> Tm158 g a -> Tm158 g B)\n -> Tm158 g a\n\nvar158 : {g : _} -> {a : _} -> Var158 g a -> Tm158 g a\nvar158 = \\ x, tm, var158, lam, app => var158 _ _ x\n\nlam158 : {g : _} -> {a : _} -> {B : _} -> Tm158 (snoc158 g a) B -> Tm158 g (arr158 a B)\nlam158 = \\ t, tm, var158, lam158, app => lam158 _ _ _ (t tm var158 lam158 app)\n\napp158 : {g:_}->{a:_}->{B:_} -> Tm158 g (arr158 a B) -> Tm158 g a -> Tm158 g B\napp158 = \\ t, u, tm, var158, lam158, app158 => app158 _ _ _ (t tm var158 lam158 app158) (u tm var158 lam158 app158)\n\nv0158 : {g:_}->{a:_} -> Tm158 (snoc158 g a) a\nv0158 = var158 vz158\n\nv1158 : {g:_}->{a:_}-> {B:_}-> Tm158 (snoc158 (snoc158 g a) B) a\nv1158 = var158 (vs158 vz158)\n\nv2158 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm158 (snoc158 (snoc158 (snoc158 g a) B) C) a\nv2158 = var158 (vs158 (vs158 vz158))\n\nv3158 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm158 (snoc158 (snoc158 (snoc158 (snoc158 g a) B) C) D) a\nv3158 = var158 (vs158 (vs158 (vs158 vz158)))\n\nv4158 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm158 (snoc158 (snoc158 (snoc158 (snoc158 (snoc158 g a) B) C) D) E) a\nv4158 = var158 (vs158 (vs158 (vs158 (vs158 vz158))))\n\ntest158 : {g:_}-> {a:_} -> Tm158 g (arr158 (arr158 a a) (arr158 a a))\ntest158 = lam158 (lam158 (app158 v1158 (app158 v1158 (app158 v1158 (app158 v1158 (app158 v1158 (app158 v1158 v0158)))))))\nTy159 : Type\nTy159 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty159 : Ty159\nempty159 = \\ _, empty, _ => empty\n\narr159 : Ty159 -> Ty159 -> Ty159\narr159 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon159 : Type\nCon159 = (Con159 : Type)\n ->(nil : Con159)\n ->(snoc : Con159 -> Ty159 -> Con159)\n -> Con159\n\nnil159 : Con159\nnil159 = \\ con, nil159, snoc => nil159\n\nsnoc159 : Con159 -> Ty159 -> Con159\nsnoc159 = \\ g, a, con, nil159, snoc159 => snoc159 (g con nil159 snoc159) a\n\nVar159 : Con159 -> Ty159 -> Type\nVar159 = \\ g, a =>\n (Var159 : Con159 -> Ty159 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var159 (snoc159 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var159 g a -> Var159 (snoc159 g b) a)\n -> Var159 g a\n\nvz159 : {g : _}-> {a : _} -> Var159 (snoc159 g a) a\nvz159 = \\ var, vz159, vs => vz159 _ _\n\nvs159 : {g : _} -> {B : _} -> {a : _} -> Var159 g a -> Var159 (snoc159 g B) a\nvs159 = \\ x, var, vz159, vs159 => vs159 _ _ _ (x var vz159 vs159)\n\nTm159 : Con159 -> Ty159 -> Type\nTm159 = \\ g, a =>\n (Tm159 : Con159 -> Ty159 -> Type)\n -> (var : (g : _) -> (a : _) -> Var159 g a -> Tm159 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm159 (snoc159 g a) B -> Tm159 g (arr159 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm159 g (arr159 a B) -> Tm159 g a -> Tm159 g B)\n -> Tm159 g a\n\nvar159 : {g : _} -> {a : _} -> Var159 g a -> Tm159 g a\nvar159 = \\ x, tm, var159, lam, app => var159 _ _ x\n\nlam159 : {g : _} -> {a : _} -> {B : _} -> Tm159 (snoc159 g a) B -> Tm159 g (arr159 a B)\nlam159 = \\ t, tm, var159, lam159, app => lam159 _ _ _ (t tm var159 lam159 app)\n\napp159 : {g:_}->{a:_}->{B:_} -> Tm159 g (arr159 a B) -> Tm159 g a -> Tm159 g B\napp159 = \\ t, u, tm, var159, lam159, app159 => app159 _ _ _ (t tm var159 lam159 app159) (u tm var159 lam159 app159)\n\nv0159 : {g:_}->{a:_} -> Tm159 (snoc159 g a) a\nv0159 = var159 vz159\n\nv1159 : {g:_}->{a:_}-> {B:_}-> Tm159 (snoc159 (snoc159 g a) B) a\nv1159 = var159 (vs159 vz159)\n\nv2159 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm159 (snoc159 (snoc159 (snoc159 g a) B) C) a\nv2159 = var159 (vs159 (vs159 vz159))\n\nv3159 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm159 (snoc159 (snoc159 (snoc159 (snoc159 g a) B) C) D) a\nv3159 = var159 (vs159 (vs159 (vs159 vz159)))\n\nv4159 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm159 (snoc159 (snoc159 (snoc159 (snoc159 (snoc159 g a) B) C) D) E) a\nv4159 = var159 (vs159 (vs159 (vs159 (vs159 vz159))))\n\ntest159 : {g:_}-> {a:_} -> Tm159 g (arr159 (arr159 a a) (arr159 a a))\ntest159 = lam159 (lam159 (app159 v1159 (app159 v1159 (app159 v1159 (app159 v1159 (app159 v1159 (app159 v1159 v0159)))))))\nTy160 : Type\nTy160 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty160 : Ty160\nempty160 = \\ _, empty, _ => empty\n\narr160 : Ty160 -> Ty160 -> Ty160\narr160 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon160 : Type\nCon160 = (Con160 : Type)\n ->(nil : Con160)\n ->(snoc : Con160 -> Ty160 -> Con160)\n -> Con160\n\nnil160 : Con160\nnil160 = \\ con, nil160, snoc => nil160\n\nsnoc160 : Con160 -> Ty160 -> Con160\nsnoc160 = \\ g, a, con, nil160, snoc160 => snoc160 (g con nil160 snoc160) a\n\nVar160 : Con160 -> Ty160 -> Type\nVar160 = \\ g, a =>\n (Var160 : Con160 -> Ty160 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var160 (snoc160 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var160 g a -> Var160 (snoc160 g b) a)\n -> Var160 g a\n\nvz160 : {g : _}-> {a : _} -> Var160 (snoc160 g a) a\nvz160 = \\ var, vz160, vs => vz160 _ _\n\nvs160 : {g : _} -> {B : _} -> {a : _} -> Var160 g a -> Var160 (snoc160 g B) a\nvs160 = \\ x, var, vz160, vs160 => vs160 _ _ _ (x var vz160 vs160)\n\nTm160 : Con160 -> Ty160 -> Type\nTm160 = \\ g, a =>\n (Tm160 : Con160 -> Ty160 -> Type)\n -> (var : (g : _) -> (a : _) -> Var160 g a -> Tm160 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm160 (snoc160 g a) B -> Tm160 g (arr160 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm160 g (arr160 a B) -> Tm160 g a -> Tm160 g B)\n -> Tm160 g a\n\nvar160 : {g : _} -> {a : _} -> Var160 g a -> Tm160 g a\nvar160 = \\ x, tm, var160, lam, app => var160 _ _ x\n\nlam160 : {g : _} -> {a : _} -> {B : _} -> Tm160 (snoc160 g a) B -> Tm160 g (arr160 a B)\nlam160 = \\ t, tm, var160, lam160, app => lam160 _ _ _ (t tm var160 lam160 app)\n\napp160 : {g:_}->{a:_}->{B:_} -> Tm160 g (arr160 a B) -> Tm160 g a -> Tm160 g B\napp160 = \\ t, u, tm, var160, lam160, app160 => app160 _ _ _ (t tm var160 lam160 app160) (u tm var160 lam160 app160)\n\nv0160 : {g:_}->{a:_} -> Tm160 (snoc160 g a) a\nv0160 = var160 vz160\n\nv1160 : {g:_}->{a:_}-> {B:_}-> Tm160 (snoc160 (snoc160 g a) B) a\nv1160 = var160 (vs160 vz160)\n\nv2160 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm160 (snoc160 (snoc160 (snoc160 g a) B) C) a\nv2160 = var160 (vs160 (vs160 vz160))\n\nv3160 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm160 (snoc160 (snoc160 (snoc160 (snoc160 g a) B) C) D) a\nv3160 = var160 (vs160 (vs160 (vs160 vz160)))\n\nv4160 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm160 (snoc160 (snoc160 (snoc160 (snoc160 (snoc160 g a) B) C) D) E) a\nv4160 = var160 (vs160 (vs160 (vs160 (vs160 vz160))))\n\ntest160 : {g:_}-> {a:_} -> Tm160 g (arr160 (arr160 a a) (arr160 a a))\ntest160 = lam160 (lam160 (app160 v1160 (app160 v1160 (app160 v1160 (app160 v1160 (app160 v1160 (app160 v1160 v0160)))))))\nTy161 : Type\nTy161 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty161 : Ty161\nempty161 = \\ _, empty, _ => empty\n\narr161 : Ty161 -> Ty161 -> Ty161\narr161 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon161 : Type\nCon161 = (Con161 : Type)\n ->(nil : Con161)\n ->(snoc : Con161 -> Ty161 -> Con161)\n -> Con161\n\nnil161 : Con161\nnil161 = \\ con, nil161, snoc => nil161\n\nsnoc161 : Con161 -> Ty161 -> Con161\nsnoc161 = \\ g, a, con, nil161, snoc161 => snoc161 (g con nil161 snoc161) a\n\nVar161 : Con161 -> Ty161 -> Type\nVar161 = \\ g, a =>\n (Var161 : Con161 -> Ty161 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var161 (snoc161 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var161 g a -> Var161 (snoc161 g b) a)\n -> Var161 g a\n\nvz161 : {g : _}-> {a : _} -> Var161 (snoc161 g a) a\nvz161 = \\ var, vz161, vs => vz161 _ _\n\nvs161 : {g : _} -> {B : _} -> {a : _} -> Var161 g a -> Var161 (snoc161 g B) a\nvs161 = \\ x, var, vz161, vs161 => vs161 _ _ _ (x var vz161 vs161)\n\nTm161 : Con161 -> Ty161 -> Type\nTm161 = \\ g, a =>\n (Tm161 : Con161 -> Ty161 -> Type)\n -> (var : (g : _) -> (a : _) -> Var161 g a -> Tm161 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm161 (snoc161 g a) B -> Tm161 g (arr161 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm161 g (arr161 a B) -> Tm161 g a -> Tm161 g B)\n -> Tm161 g a\n\nvar161 : {g : _} -> {a : _} -> Var161 g a -> Tm161 g a\nvar161 = \\ x, tm, var161, lam, app => var161 _ _ x\n\nlam161 : {g : _} -> {a : _} -> {B : _} -> Tm161 (snoc161 g a) B -> Tm161 g (arr161 a B)\nlam161 = \\ t, tm, var161, lam161, app => lam161 _ _ _ (t tm var161 lam161 app)\n\napp161 : {g:_}->{a:_}->{B:_} -> Tm161 g (arr161 a B) -> Tm161 g a -> Tm161 g B\napp161 = \\ t, u, tm, var161, lam161, app161 => app161 _ _ _ (t tm var161 lam161 app161) (u tm var161 lam161 app161)\n\nv0161 : {g:_}->{a:_} -> Tm161 (snoc161 g a) a\nv0161 = var161 vz161\n\nv1161 : {g:_}->{a:_}-> {B:_}-> Tm161 (snoc161 (snoc161 g a) B) a\nv1161 = var161 (vs161 vz161)\n\nv2161 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm161 (snoc161 (snoc161 (snoc161 g a) B) C) a\nv2161 = var161 (vs161 (vs161 vz161))\n\nv3161 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm161 (snoc161 (snoc161 (snoc161 (snoc161 g a) B) C) D) a\nv3161 = var161 (vs161 (vs161 (vs161 vz161)))\n\nv4161 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm161 (snoc161 (snoc161 (snoc161 (snoc161 (snoc161 g a) B) C) D) E) a\nv4161 = var161 (vs161 (vs161 (vs161 (vs161 vz161))))\n\ntest161 : {g:_}-> {a:_} -> Tm161 g (arr161 (arr161 a a) (arr161 a a))\ntest161 = lam161 (lam161 (app161 v1161 (app161 v1161 (app161 v1161 (app161 v1161 (app161 v1161 (app161 v1161 v0161)))))))\nTy162 : Type\nTy162 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty162 : Ty162\nempty162 = \\ _, empty, _ => empty\n\narr162 : Ty162 -> Ty162 -> Ty162\narr162 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon162 : Type\nCon162 = (Con162 : Type)\n ->(nil : Con162)\n ->(snoc : Con162 -> Ty162 -> Con162)\n -> Con162\n\nnil162 : Con162\nnil162 = \\ con, nil162, snoc => nil162\n\nsnoc162 : Con162 -> Ty162 -> Con162\nsnoc162 = \\ g, a, con, nil162, snoc162 => snoc162 (g con nil162 snoc162) a\n\nVar162 : Con162 -> Ty162 -> Type\nVar162 = \\ g, a =>\n (Var162 : Con162 -> Ty162 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var162 (snoc162 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var162 g a -> Var162 (snoc162 g b) a)\n -> Var162 g a\n\nvz162 : {g : _}-> {a : _} -> Var162 (snoc162 g a) a\nvz162 = \\ var, vz162, vs => vz162 _ _\n\nvs162 : {g : _} -> {B : _} -> {a : _} -> Var162 g a -> Var162 (snoc162 g B) a\nvs162 = \\ x, var, vz162, vs162 => vs162 _ _ _ (x var vz162 vs162)\n\nTm162 : Con162 -> Ty162 -> Type\nTm162 = \\ g, a =>\n (Tm162 : Con162 -> Ty162 -> Type)\n -> (var : (g : _) -> (a : _) -> Var162 g a -> Tm162 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm162 (snoc162 g a) B -> Tm162 g (arr162 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm162 g (arr162 a B) -> Tm162 g a -> Tm162 g B)\n -> Tm162 g a\n\nvar162 : {g : _} -> {a : _} -> Var162 g a -> Tm162 g a\nvar162 = \\ x, tm, var162, lam, app => var162 _ _ x\n\nlam162 : {g : _} -> {a : _} -> {B : _} -> Tm162 (snoc162 g a) B -> Tm162 g (arr162 a B)\nlam162 = \\ t, tm, var162, lam162, app => lam162 _ _ _ (t tm var162 lam162 app)\n\napp162 : {g:_}->{a:_}->{B:_} -> Tm162 g (arr162 a B) -> Tm162 g a -> Tm162 g B\napp162 = \\ t, u, tm, var162, lam162, app162 => app162 _ _ _ (t tm var162 lam162 app162) (u tm var162 lam162 app162)\n\nv0162 : {g:_}->{a:_} -> Tm162 (snoc162 g a) a\nv0162 = var162 vz162\n\nv1162 : {g:_}->{a:_}-> {B:_}-> Tm162 (snoc162 (snoc162 g a) B) a\nv1162 = var162 (vs162 vz162)\n\nv2162 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm162 (snoc162 (snoc162 (snoc162 g a) B) C) a\nv2162 = var162 (vs162 (vs162 vz162))\n\nv3162 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm162 (snoc162 (snoc162 (snoc162 (snoc162 g a) B) C) D) a\nv3162 = var162 (vs162 (vs162 (vs162 vz162)))\n\nv4162 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm162 (snoc162 (snoc162 (snoc162 (snoc162 (snoc162 g a) B) C) D) E) a\nv4162 = var162 (vs162 (vs162 (vs162 (vs162 vz162))))\n\ntest162 : {g:_}-> {a:_} -> Tm162 g (arr162 (arr162 a a) (arr162 a a))\ntest162 = lam162 (lam162 (app162 v1162 (app162 v1162 (app162 v1162 (app162 v1162 (app162 v1162 (app162 v1162 v0162)))))))\nTy163 : Type\nTy163 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty163 : Ty163\nempty163 = \\ _, empty, _ => empty\n\narr163 : Ty163 -> Ty163 -> Ty163\narr163 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon163 : Type\nCon163 = (Con163 : Type)\n ->(nil : Con163)\n ->(snoc : Con163 -> Ty163 -> Con163)\n -> Con163\n\nnil163 : Con163\nnil163 = \\ con, nil163, snoc => nil163\n\nsnoc163 : Con163 -> Ty163 -> Con163\nsnoc163 = \\ g, a, con, nil163, snoc163 => snoc163 (g con nil163 snoc163) a\n\nVar163 : Con163 -> Ty163 -> Type\nVar163 = \\ g, a =>\n (Var163 : Con163 -> Ty163 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var163 (snoc163 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var163 g a -> Var163 (snoc163 g b) a)\n -> Var163 g a\n\nvz163 : {g : _}-> {a : _} -> Var163 (snoc163 g a) a\nvz163 = \\ var, vz163, vs => vz163 _ _\n\nvs163 : {g : _} -> {B : _} -> {a : _} -> Var163 g a -> Var163 (snoc163 g B) a\nvs163 = \\ x, var, vz163, vs163 => vs163 _ _ _ (x var vz163 vs163)\n\nTm163 : Con163 -> Ty163 -> Type\nTm163 = \\ g, a =>\n (Tm163 : Con163 -> Ty163 -> Type)\n -> (var : (g : _) -> (a : _) -> Var163 g a -> Tm163 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm163 (snoc163 g a) B -> Tm163 g (arr163 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm163 g (arr163 a B) -> Tm163 g a -> Tm163 g B)\n -> Tm163 g a\n\nvar163 : {g : _} -> {a : _} -> Var163 g a -> Tm163 g a\nvar163 = \\ x, tm, var163, lam, app => var163 _ _ x\n\nlam163 : {g : _} -> {a : _} -> {B : _} -> Tm163 (snoc163 g a) B -> Tm163 g (arr163 a B)\nlam163 = \\ t, tm, var163, lam163, app => lam163 _ _ _ (t tm var163 lam163 app)\n\napp163 : {g:_}->{a:_}->{B:_} -> Tm163 g (arr163 a B) -> Tm163 g a -> Tm163 g B\napp163 = \\ t, u, tm, var163, lam163, app163 => app163 _ _ _ (t tm var163 lam163 app163) (u tm var163 lam163 app163)\n\nv0163 : {g:_}->{a:_} -> Tm163 (snoc163 g a) a\nv0163 = var163 vz163\n\nv1163 : {g:_}->{a:_}-> {B:_}-> Tm163 (snoc163 (snoc163 g a) B) a\nv1163 = var163 (vs163 vz163)\n\nv2163 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm163 (snoc163 (snoc163 (snoc163 g a) B) C) a\nv2163 = var163 (vs163 (vs163 vz163))\n\nv3163 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm163 (snoc163 (snoc163 (snoc163 (snoc163 g a) B) C) D) a\nv3163 = var163 (vs163 (vs163 (vs163 vz163)))\n\nv4163 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm163 (snoc163 (snoc163 (snoc163 (snoc163 (snoc163 g a) B) C) D) E) a\nv4163 = var163 (vs163 (vs163 (vs163 (vs163 vz163))))\n\ntest163 : {g:_}-> {a:_} -> Tm163 g (arr163 (arr163 a a) (arr163 a a))\ntest163 = lam163 (lam163 (app163 v1163 (app163 v1163 (app163 v1163 (app163 v1163 (app163 v1163 (app163 v1163 v0163)))))))\nTy164 : Type\nTy164 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty164 : Ty164\nempty164 = \\ _, empty, _ => empty\n\narr164 : Ty164 -> Ty164 -> Ty164\narr164 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon164 : Type\nCon164 = (Con164 : Type)\n ->(nil : Con164)\n ->(snoc : Con164 -> Ty164 -> Con164)\n -> Con164\n\nnil164 : Con164\nnil164 = \\ con, nil164, snoc => nil164\n\nsnoc164 : Con164 -> Ty164 -> Con164\nsnoc164 = \\ g, a, con, nil164, snoc164 => snoc164 (g con nil164 snoc164) a\n\nVar164 : Con164 -> Ty164 -> Type\nVar164 = \\ g, a =>\n (Var164 : Con164 -> Ty164 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var164 (snoc164 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var164 g a -> Var164 (snoc164 g b) a)\n -> Var164 g a\n\nvz164 : {g : _}-> {a : _} -> Var164 (snoc164 g a) a\nvz164 = \\ var, vz164, vs => vz164 _ _\n\nvs164 : {g : _} -> {B : _} -> {a : _} -> Var164 g a -> Var164 (snoc164 g B) a\nvs164 = \\ x, var, vz164, vs164 => vs164 _ _ _ (x var vz164 vs164)\n\nTm164 : Con164 -> Ty164 -> Type\nTm164 = \\ g, a =>\n (Tm164 : Con164 -> Ty164 -> Type)\n -> (var : (g : _) -> (a : _) -> Var164 g a -> Tm164 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm164 (snoc164 g a) B -> Tm164 g (arr164 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm164 g (arr164 a B) -> Tm164 g a -> Tm164 g B)\n -> Tm164 g a\n\nvar164 : {g : _} -> {a : _} -> Var164 g a -> Tm164 g a\nvar164 = \\ x, tm, var164, lam, app => var164 _ _ x\n\nlam164 : {g : _} -> {a : _} -> {B : _} -> Tm164 (snoc164 g a) B -> Tm164 g (arr164 a B)\nlam164 = \\ t, tm, var164, lam164, app => lam164 _ _ _ (t tm var164 lam164 app)\n\napp164 : {g:_}->{a:_}->{B:_} -> Tm164 g (arr164 a B) -> Tm164 g a -> Tm164 g B\napp164 = \\ t, u, tm, var164, lam164, app164 => app164 _ _ _ (t tm var164 lam164 app164) (u tm var164 lam164 app164)\n\nv0164 : {g:_}->{a:_} -> Tm164 (snoc164 g a) a\nv0164 = var164 vz164\n\nv1164 : {g:_}->{a:_}-> {B:_}-> Tm164 (snoc164 (snoc164 g a) B) a\nv1164 = var164 (vs164 vz164)\n\nv2164 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm164 (snoc164 (snoc164 (snoc164 g a) B) C) a\nv2164 = var164 (vs164 (vs164 vz164))\n\nv3164 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm164 (snoc164 (snoc164 (snoc164 (snoc164 g a) B) C) D) a\nv3164 = var164 (vs164 (vs164 (vs164 vz164)))\n\nv4164 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm164 (snoc164 (snoc164 (snoc164 (snoc164 (snoc164 g a) B) C) D) E) a\nv4164 = var164 (vs164 (vs164 (vs164 (vs164 vz164))))\n\ntest164 : {g:_}-> {a:_} -> Tm164 g (arr164 (arr164 a a) (arr164 a a))\ntest164 = lam164 (lam164 (app164 v1164 (app164 v1164 (app164 v1164 (app164 v1164 (app164 v1164 (app164 v1164 v0164)))))))\nTy165 : Type\nTy165 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty165 : Ty165\nempty165 = \\ _, empty, _ => empty\n\narr165 : Ty165 -> Ty165 -> Ty165\narr165 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon165 : Type\nCon165 = (Con165 : Type)\n ->(nil : Con165)\n ->(snoc : Con165 -> Ty165 -> Con165)\n -> Con165\n\nnil165 : Con165\nnil165 = \\ con, nil165, snoc => nil165\n\nsnoc165 : Con165 -> Ty165 -> Con165\nsnoc165 = \\ g, a, con, nil165, snoc165 => snoc165 (g con nil165 snoc165) a\n\nVar165 : Con165 -> Ty165 -> Type\nVar165 = \\ g, a =>\n (Var165 : Con165 -> Ty165 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var165 (snoc165 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var165 g a -> Var165 (snoc165 g b) a)\n -> Var165 g a\n\nvz165 : {g : _}-> {a : _} -> Var165 (snoc165 g a) a\nvz165 = \\ var, vz165, vs => vz165 _ _\n\nvs165 : {g : _} -> {B : _} -> {a : _} -> Var165 g a -> Var165 (snoc165 g B) a\nvs165 = \\ x, var, vz165, vs165 => vs165 _ _ _ (x var vz165 vs165)\n\nTm165 : Con165 -> Ty165 -> Type\nTm165 = \\ g, a =>\n (Tm165 : Con165 -> Ty165 -> Type)\n -> (var : (g : _) -> (a : _) -> Var165 g a -> Tm165 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm165 (snoc165 g a) B -> Tm165 g (arr165 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm165 g (arr165 a B) -> Tm165 g a -> Tm165 g B)\n -> Tm165 g a\n\nvar165 : {g : _} -> {a : _} -> Var165 g a -> Tm165 g a\nvar165 = \\ x, tm, var165, lam, app => var165 _ _ x\n\nlam165 : {g : _} -> {a : _} -> {B : _} -> Tm165 (snoc165 g a) B -> Tm165 g (arr165 a B)\nlam165 = \\ t, tm, var165, lam165, app => lam165 _ _ _ (t tm var165 lam165 app)\n\napp165 : {g:_}->{a:_}->{B:_} -> Tm165 g (arr165 a B) -> Tm165 g a -> Tm165 g B\napp165 = \\ t, u, tm, var165, lam165, app165 => app165 _ _ _ (t tm var165 lam165 app165) (u tm var165 lam165 app165)\n\nv0165 : {g:_}->{a:_} -> Tm165 (snoc165 g a) a\nv0165 = var165 vz165\n\nv1165 : {g:_}->{a:_}-> {B:_}-> Tm165 (snoc165 (snoc165 g a) B) a\nv1165 = var165 (vs165 vz165)\n\nv2165 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm165 (snoc165 (snoc165 (snoc165 g a) B) C) a\nv2165 = var165 (vs165 (vs165 vz165))\n\nv3165 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm165 (snoc165 (snoc165 (snoc165 (snoc165 g a) B) C) D) a\nv3165 = var165 (vs165 (vs165 (vs165 vz165)))\n\nv4165 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm165 (snoc165 (snoc165 (snoc165 (snoc165 (snoc165 g a) B) C) D) E) a\nv4165 = var165 (vs165 (vs165 (vs165 (vs165 vz165))))\n\ntest165 : {g:_}-> {a:_} -> Tm165 g (arr165 (arr165 a a) (arr165 a a))\ntest165 = lam165 (lam165 (app165 v1165 (app165 v1165 (app165 v1165 (app165 v1165 (app165 v1165 (app165 v1165 v0165)))))))\nTy166 : Type\nTy166 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty166 : Ty166\nempty166 = \\ _, empty, _ => empty\n\narr166 : Ty166 -> Ty166 -> Ty166\narr166 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon166 : Type\nCon166 = (Con166 : Type)\n ->(nil : Con166)\n ->(snoc : Con166 -> Ty166 -> Con166)\n -> Con166\n\nnil166 : Con166\nnil166 = \\ con, nil166, snoc => nil166\n\nsnoc166 : Con166 -> Ty166 -> Con166\nsnoc166 = \\ g, a, con, nil166, snoc166 => snoc166 (g con nil166 snoc166) a\n\nVar166 : Con166 -> Ty166 -> Type\nVar166 = \\ g, a =>\n (Var166 : Con166 -> Ty166 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var166 (snoc166 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var166 g a -> Var166 (snoc166 g b) a)\n -> Var166 g a\n\nvz166 : {g : _}-> {a : _} -> Var166 (snoc166 g a) a\nvz166 = \\ var, vz166, vs => vz166 _ _\n\nvs166 : {g : _} -> {B : _} -> {a : _} -> Var166 g a -> Var166 (snoc166 g B) a\nvs166 = \\ x, var, vz166, vs166 => vs166 _ _ _ (x var vz166 vs166)\n\nTm166 : Con166 -> Ty166 -> Type\nTm166 = \\ g, a =>\n (Tm166 : Con166 -> Ty166 -> Type)\n -> (var : (g : _) -> (a : _) -> Var166 g a -> Tm166 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm166 (snoc166 g a) B -> Tm166 g (arr166 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm166 g (arr166 a B) -> Tm166 g a -> Tm166 g B)\n -> Tm166 g a\n\nvar166 : {g : _} -> {a : _} -> Var166 g a -> Tm166 g a\nvar166 = \\ x, tm, var166, lam, app => var166 _ _ x\n\nlam166 : {g : _} -> {a : _} -> {B : _} -> Tm166 (snoc166 g a) B -> Tm166 g (arr166 a B)\nlam166 = \\ t, tm, var166, lam166, app => lam166 _ _ _ (t tm var166 lam166 app)\n\napp166 : {g:_}->{a:_}->{B:_} -> Tm166 g (arr166 a B) -> Tm166 g a -> Tm166 g B\napp166 = \\ t, u, tm, var166, lam166, app166 => app166 _ _ _ (t tm var166 lam166 app166) (u tm var166 lam166 app166)\n\nv0166 : {g:_}->{a:_} -> Tm166 (snoc166 g a) a\nv0166 = var166 vz166\n\nv1166 : {g:_}->{a:_}-> {B:_}-> Tm166 (snoc166 (snoc166 g a) B) a\nv1166 = var166 (vs166 vz166)\n\nv2166 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm166 (snoc166 (snoc166 (snoc166 g a) B) C) a\nv2166 = var166 (vs166 (vs166 vz166))\n\nv3166 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm166 (snoc166 (snoc166 (snoc166 (snoc166 g a) B) C) D) a\nv3166 = var166 (vs166 (vs166 (vs166 vz166)))\n\nv4166 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm166 (snoc166 (snoc166 (snoc166 (snoc166 (snoc166 g a) B) C) D) E) a\nv4166 = var166 (vs166 (vs166 (vs166 (vs166 vz166))))\n\ntest166 : {g:_}-> {a:_} -> Tm166 g (arr166 (arr166 a a) (arr166 a a))\ntest166 = lam166 (lam166 (app166 v1166 (app166 v1166 (app166 v1166 (app166 v1166 (app166 v1166 (app166 v1166 v0166)))))))\nTy167 : Type\nTy167 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty167 : Ty167\nempty167 = \\ _, empty, _ => empty\n\narr167 : Ty167 -> Ty167 -> Ty167\narr167 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon167 : Type\nCon167 = (Con167 : Type)\n ->(nil : Con167)\n ->(snoc : Con167 -> Ty167 -> Con167)\n -> Con167\n\nnil167 : Con167\nnil167 = \\ con, nil167, snoc => nil167\n\nsnoc167 : Con167 -> Ty167 -> Con167\nsnoc167 = \\ g, a, con, nil167, snoc167 => snoc167 (g con nil167 snoc167) a\n\nVar167 : Con167 -> Ty167 -> Type\nVar167 = \\ g, a =>\n (Var167 : Con167 -> Ty167 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var167 (snoc167 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var167 g a -> Var167 (snoc167 g b) a)\n -> Var167 g a\n\nvz167 : {g : _}-> {a : _} -> Var167 (snoc167 g a) a\nvz167 = \\ var, vz167, vs => vz167 _ _\n\nvs167 : {g : _} -> {B : _} -> {a : _} -> Var167 g a -> Var167 (snoc167 g B) a\nvs167 = \\ x, var, vz167, vs167 => vs167 _ _ _ (x var vz167 vs167)\n\nTm167 : Con167 -> Ty167 -> Type\nTm167 = \\ g, a =>\n (Tm167 : Con167 -> Ty167 -> Type)\n -> (var : (g : _) -> (a : _) -> Var167 g a -> Tm167 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm167 (snoc167 g a) B -> Tm167 g (arr167 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm167 g (arr167 a B) -> Tm167 g a -> Tm167 g B)\n -> Tm167 g a\n\nvar167 : {g : _} -> {a : _} -> Var167 g a -> Tm167 g a\nvar167 = \\ x, tm, var167, lam, app => var167 _ _ x\n\nlam167 : {g : _} -> {a : _} -> {B : _} -> Tm167 (snoc167 g a) B -> Tm167 g (arr167 a B)\nlam167 = \\ t, tm, var167, lam167, app => lam167 _ _ _ (t tm var167 lam167 app)\n\napp167 : {g:_}->{a:_}->{B:_} -> Tm167 g (arr167 a B) -> Tm167 g a -> Tm167 g B\napp167 = \\ t, u, tm, var167, lam167, app167 => app167 _ _ _ (t tm var167 lam167 app167) (u tm var167 lam167 app167)\n\nv0167 : {g:_}->{a:_} -> Tm167 (snoc167 g a) a\nv0167 = var167 vz167\n\nv1167 : {g:_}->{a:_}-> {B:_}-> Tm167 (snoc167 (snoc167 g a) B) a\nv1167 = var167 (vs167 vz167)\n\nv2167 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm167 (snoc167 (snoc167 (snoc167 g a) B) C) a\nv2167 = var167 (vs167 (vs167 vz167))\n\nv3167 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm167 (snoc167 (snoc167 (snoc167 (snoc167 g a) B) C) D) a\nv3167 = var167 (vs167 (vs167 (vs167 vz167)))\n\nv4167 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm167 (snoc167 (snoc167 (snoc167 (snoc167 (snoc167 g a) B) C) D) E) a\nv4167 = var167 (vs167 (vs167 (vs167 (vs167 vz167))))\n\ntest167 : {g:_}-> {a:_} -> Tm167 g (arr167 (arr167 a a) (arr167 a a))\ntest167 = lam167 (lam167 (app167 v1167 (app167 v1167 (app167 v1167 (app167 v1167 (app167 v1167 (app167 v1167 v0167)))))))\nTy168 : Type\nTy168 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty168 : Ty168\nempty168 = \\ _, empty, _ => empty\n\narr168 : Ty168 -> Ty168 -> Ty168\narr168 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon168 : Type\nCon168 = (Con168 : Type)\n ->(nil : Con168)\n ->(snoc : Con168 -> Ty168 -> Con168)\n -> Con168\n\nnil168 : Con168\nnil168 = \\ con, nil168, snoc => nil168\n\nsnoc168 : Con168 -> Ty168 -> Con168\nsnoc168 = \\ g, a, con, nil168, snoc168 => snoc168 (g con nil168 snoc168) a\n\nVar168 : Con168 -> Ty168 -> Type\nVar168 = \\ g, a =>\n (Var168 : Con168 -> Ty168 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var168 (snoc168 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var168 g a -> Var168 (snoc168 g b) a)\n -> Var168 g a\n\nvz168 : {g : _}-> {a : _} -> Var168 (snoc168 g a) a\nvz168 = \\ var, vz168, vs => vz168 _ _\n\nvs168 : {g : _} -> {B : _} -> {a : _} -> Var168 g a -> Var168 (snoc168 g B) a\nvs168 = \\ x, var, vz168, vs168 => vs168 _ _ _ (x var vz168 vs168)\n\nTm168 : Con168 -> Ty168 -> Type\nTm168 = \\ g, a =>\n (Tm168 : Con168 -> Ty168 -> Type)\n -> (var : (g : _) -> (a : _) -> Var168 g a -> Tm168 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm168 (snoc168 g a) B -> Tm168 g (arr168 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm168 g (arr168 a B) -> Tm168 g a -> Tm168 g B)\n -> Tm168 g a\n\nvar168 : {g : _} -> {a : _} -> Var168 g a -> Tm168 g a\nvar168 = \\ x, tm, var168, lam, app => var168 _ _ x\n\nlam168 : {g : _} -> {a : _} -> {B : _} -> Tm168 (snoc168 g a) B -> Tm168 g (arr168 a B)\nlam168 = \\ t, tm, var168, lam168, app => lam168 _ _ _ (t tm var168 lam168 app)\n\napp168 : {g:_}->{a:_}->{B:_} -> Tm168 g (arr168 a B) -> Tm168 g a -> Tm168 g B\napp168 = \\ t, u, tm, var168, lam168, app168 => app168 _ _ _ (t tm var168 lam168 app168) (u tm var168 lam168 app168)\n\nv0168 : {g:_}->{a:_} -> Tm168 (snoc168 g a) a\nv0168 = var168 vz168\n\nv1168 : {g:_}->{a:_}-> {B:_}-> Tm168 (snoc168 (snoc168 g a) B) a\nv1168 = var168 (vs168 vz168)\n\nv2168 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm168 (snoc168 (snoc168 (snoc168 g a) B) C) a\nv2168 = var168 (vs168 (vs168 vz168))\n\nv3168 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm168 (snoc168 (snoc168 (snoc168 (snoc168 g a) B) C) D) a\nv3168 = var168 (vs168 (vs168 (vs168 vz168)))\n\nv4168 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm168 (snoc168 (snoc168 (snoc168 (snoc168 (snoc168 g a) B) C) D) E) a\nv4168 = var168 (vs168 (vs168 (vs168 (vs168 vz168))))\n\ntest168 : {g:_}-> {a:_} -> Tm168 g (arr168 (arr168 a a) (arr168 a a))\ntest168 = lam168 (lam168 (app168 v1168 (app168 v1168 (app168 v1168 (app168 v1168 (app168 v1168 (app168 v1168 v0168)))))))\nTy169 : Type\nTy169 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty169 : Ty169\nempty169 = \\ _, empty, _ => empty\n\narr169 : Ty169 -> Ty169 -> Ty169\narr169 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon169 : Type\nCon169 = (Con169 : Type)\n ->(nil : Con169)\n ->(snoc : Con169 -> Ty169 -> Con169)\n -> Con169\n\nnil169 : Con169\nnil169 = \\ con, nil169, snoc => nil169\n\nsnoc169 : Con169 -> Ty169 -> Con169\nsnoc169 = \\ g, a, con, nil169, snoc169 => snoc169 (g con nil169 snoc169) a\n\nVar169 : Con169 -> Ty169 -> Type\nVar169 = \\ g, a =>\n (Var169 : Con169 -> Ty169 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var169 (snoc169 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var169 g a -> Var169 (snoc169 g b) a)\n -> Var169 g a\n\nvz169 : {g : _}-> {a : _} -> Var169 (snoc169 g a) a\nvz169 = \\ var, vz169, vs => vz169 _ _\n\nvs169 : {g : _} -> {B : _} -> {a : _} -> Var169 g a -> Var169 (snoc169 g B) a\nvs169 = \\ x, var, vz169, vs169 => vs169 _ _ _ (x var vz169 vs169)\n\nTm169 : Con169 -> Ty169 -> Type\nTm169 = \\ g, a =>\n (Tm169 : Con169 -> Ty169 -> Type)\n -> (var : (g : _) -> (a : _) -> Var169 g a -> Tm169 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm169 (snoc169 g a) B -> Tm169 g (arr169 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm169 g (arr169 a B) -> Tm169 g a -> Tm169 g B)\n -> Tm169 g a\n\nvar169 : {g : _} -> {a : _} -> Var169 g a -> Tm169 g a\nvar169 = \\ x, tm, var169, lam, app => var169 _ _ x\n\nlam169 : {g : _} -> {a : _} -> {B : _} -> Tm169 (snoc169 g a) B -> Tm169 g (arr169 a B)\nlam169 = \\ t, tm, var169, lam169, app => lam169 _ _ _ (t tm var169 lam169 app)\n\napp169 : {g:_}->{a:_}->{B:_} -> Tm169 g (arr169 a B) -> Tm169 g a -> Tm169 g B\napp169 = \\ t, u, tm, var169, lam169, app169 => app169 _ _ _ (t tm var169 lam169 app169) (u tm var169 lam169 app169)\n\nv0169 : {g:_}->{a:_} -> Tm169 (snoc169 g a) a\nv0169 = var169 vz169\n\nv1169 : {g:_}->{a:_}-> {B:_}-> Tm169 (snoc169 (snoc169 g a) B) a\nv1169 = var169 (vs169 vz169)\n\nv2169 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm169 (snoc169 (snoc169 (snoc169 g a) B) C) a\nv2169 = var169 (vs169 (vs169 vz169))\n\nv3169 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm169 (snoc169 (snoc169 (snoc169 (snoc169 g a) B) C) D) a\nv3169 = var169 (vs169 (vs169 (vs169 vz169)))\n\nv4169 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm169 (snoc169 (snoc169 (snoc169 (snoc169 (snoc169 g a) B) C) D) E) a\nv4169 = var169 (vs169 (vs169 (vs169 (vs169 vz169))))\n\ntest169 : {g:_}-> {a:_} -> Tm169 g (arr169 (arr169 a a) (arr169 a a))\ntest169 = lam169 (lam169 (app169 v1169 (app169 v1169 (app169 v1169 (app169 v1169 (app169 v1169 (app169 v1169 v0169)))))))\nTy170 : Type\nTy170 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty170 : Ty170\nempty170 = \\ _, empty, _ => empty\n\narr170 : Ty170 -> Ty170 -> Ty170\narr170 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon170 : Type\nCon170 = (Con170 : Type)\n ->(nil : Con170)\n ->(snoc : Con170 -> Ty170 -> Con170)\n -> Con170\n\nnil170 : Con170\nnil170 = \\ con, nil170, snoc => nil170\n\nsnoc170 : Con170 -> Ty170 -> Con170\nsnoc170 = \\ g, a, con, nil170, snoc170 => snoc170 (g con nil170 snoc170) a\n\nVar170 : Con170 -> Ty170 -> Type\nVar170 = \\ g, a =>\n (Var170 : Con170 -> Ty170 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var170 (snoc170 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var170 g a -> Var170 (snoc170 g b) a)\n -> Var170 g a\n\nvz170 : {g : _}-> {a : _} -> Var170 (snoc170 g a) a\nvz170 = \\ var, vz170, vs => vz170 _ _\n\nvs170 : {g : _} -> {B : _} -> {a : _} -> Var170 g a -> Var170 (snoc170 g B) a\nvs170 = \\ x, var, vz170, vs170 => vs170 _ _ _ (x var vz170 vs170)\n\nTm170 : Con170 -> Ty170 -> Type\nTm170 = \\ g, a =>\n (Tm170 : Con170 -> Ty170 -> Type)\n -> (var : (g : _) -> (a : _) -> Var170 g a -> Tm170 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm170 (snoc170 g a) B -> Tm170 g (arr170 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm170 g (arr170 a B) -> Tm170 g a -> Tm170 g B)\n -> Tm170 g a\n\nvar170 : {g : _} -> {a : _} -> Var170 g a -> Tm170 g a\nvar170 = \\ x, tm, var170, lam, app => var170 _ _ x\n\nlam170 : {g : _} -> {a : _} -> {B : _} -> Tm170 (snoc170 g a) B -> Tm170 g (arr170 a B)\nlam170 = \\ t, tm, var170, lam170, app => lam170 _ _ _ (t tm var170 lam170 app)\n\napp170 : {g:_}->{a:_}->{B:_} -> Tm170 g (arr170 a B) -> Tm170 g a -> Tm170 g B\napp170 = \\ t, u, tm, var170, lam170, app170 => app170 _ _ _ (t tm var170 lam170 app170) (u tm var170 lam170 app170)\n\nv0170 : {g:_}->{a:_} -> Tm170 (snoc170 g a) a\nv0170 = var170 vz170\n\nv1170 : {g:_}->{a:_}-> {B:_}-> Tm170 (snoc170 (snoc170 g a) B) a\nv1170 = var170 (vs170 vz170)\n\nv2170 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm170 (snoc170 (snoc170 (snoc170 g a) B) C) a\nv2170 = var170 (vs170 (vs170 vz170))\n\nv3170 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm170 (snoc170 (snoc170 (snoc170 (snoc170 g a) B) C) D) a\nv3170 = var170 (vs170 (vs170 (vs170 vz170)))\n\nv4170 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm170 (snoc170 (snoc170 (snoc170 (snoc170 (snoc170 g a) B) C) D) E) a\nv4170 = var170 (vs170 (vs170 (vs170 (vs170 vz170))))\n\ntest170 : {g:_}-> {a:_} -> Tm170 g (arr170 (arr170 a a) (arr170 a a))\ntest170 = lam170 (lam170 (app170 v1170 (app170 v1170 (app170 v1170 (app170 v1170 (app170 v1170 (app170 v1170 v0170)))))))\nTy171 : Type\nTy171 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty171 : Ty171\nempty171 = \\ _, empty, _ => empty\n\narr171 : Ty171 -> Ty171 -> Ty171\narr171 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon171 : Type\nCon171 = (Con171 : Type)\n ->(nil : Con171)\n ->(snoc : Con171 -> Ty171 -> Con171)\n -> Con171\n\nnil171 : Con171\nnil171 = \\ con, nil171, snoc => nil171\n\nsnoc171 : Con171 -> Ty171 -> Con171\nsnoc171 = \\ g, a, con, nil171, snoc171 => snoc171 (g con nil171 snoc171) a\n\nVar171 : Con171 -> Ty171 -> Type\nVar171 = \\ g, a =>\n (Var171 : Con171 -> Ty171 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var171 (snoc171 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var171 g a -> Var171 (snoc171 g b) a)\n -> Var171 g a\n\nvz171 : {g : _}-> {a : _} -> Var171 (snoc171 g a) a\nvz171 = \\ var, vz171, vs => vz171 _ _\n\nvs171 : {g : _} -> {B : _} -> {a : _} -> Var171 g a -> Var171 (snoc171 g B) a\nvs171 = \\ x, var, vz171, vs171 => vs171 _ _ _ (x var vz171 vs171)\n\nTm171 : Con171 -> Ty171 -> Type\nTm171 = \\ g, a =>\n (Tm171 : Con171 -> Ty171 -> Type)\n -> (var : (g : _) -> (a : _) -> Var171 g a -> Tm171 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm171 (snoc171 g a) B -> Tm171 g (arr171 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm171 g (arr171 a B) -> Tm171 g a -> Tm171 g B)\n -> Tm171 g a\n\nvar171 : {g : _} -> {a : _} -> Var171 g a -> Tm171 g a\nvar171 = \\ x, tm, var171, lam, app => var171 _ _ x\n\nlam171 : {g : _} -> {a : _} -> {B : _} -> Tm171 (snoc171 g a) B -> Tm171 g (arr171 a B)\nlam171 = \\ t, tm, var171, lam171, app => lam171 _ _ _ (t tm var171 lam171 app)\n\napp171 : {g:_}->{a:_}->{B:_} -> Tm171 g (arr171 a B) -> Tm171 g a -> Tm171 g B\napp171 = \\ t, u, tm, var171, lam171, app171 => app171 _ _ _ (t tm var171 lam171 app171) (u tm var171 lam171 app171)\n\nv0171 : {g:_}->{a:_} -> Tm171 (snoc171 g a) a\nv0171 = var171 vz171\n\nv1171 : {g:_}->{a:_}-> {B:_}-> Tm171 (snoc171 (snoc171 g a) B) a\nv1171 = var171 (vs171 vz171)\n\nv2171 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm171 (snoc171 (snoc171 (snoc171 g a) B) C) a\nv2171 = var171 (vs171 (vs171 vz171))\n\nv3171 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm171 (snoc171 (snoc171 (snoc171 (snoc171 g a) B) C) D) a\nv3171 = var171 (vs171 (vs171 (vs171 vz171)))\n\nv4171 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm171 (snoc171 (snoc171 (snoc171 (snoc171 (snoc171 g a) B) C) D) E) a\nv4171 = var171 (vs171 (vs171 (vs171 (vs171 vz171))))\n\ntest171 : {g:_}-> {a:_} -> Tm171 g (arr171 (arr171 a a) (arr171 a a))\ntest171 = lam171 (lam171 (app171 v1171 (app171 v1171 (app171 v1171 (app171 v1171 (app171 v1171 (app171 v1171 v0171)))))))\nTy172 : Type\nTy172 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty172 : Ty172\nempty172 = \\ _, empty, _ => empty\n\narr172 : Ty172 -> Ty172 -> Ty172\narr172 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon172 : Type\nCon172 = (Con172 : Type)\n ->(nil : Con172)\n ->(snoc : Con172 -> Ty172 -> Con172)\n -> Con172\n\nnil172 : Con172\nnil172 = \\ con, nil172, snoc => nil172\n\nsnoc172 : Con172 -> Ty172 -> Con172\nsnoc172 = \\ g, a, con, nil172, snoc172 => snoc172 (g con nil172 snoc172) a\n\nVar172 : Con172 -> Ty172 -> Type\nVar172 = \\ g, a =>\n (Var172 : Con172 -> Ty172 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var172 (snoc172 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var172 g a -> Var172 (snoc172 g b) a)\n -> Var172 g a\n\nvz172 : {g : _}-> {a : _} -> Var172 (snoc172 g a) a\nvz172 = \\ var, vz172, vs => vz172 _ _\n\nvs172 : {g : _} -> {B : _} -> {a : _} -> Var172 g a -> Var172 (snoc172 g B) a\nvs172 = \\ x, var, vz172, vs172 => vs172 _ _ _ (x var vz172 vs172)\n\nTm172 : Con172 -> Ty172 -> Type\nTm172 = \\ g, a =>\n (Tm172 : Con172 -> Ty172 -> Type)\n -> (var : (g : _) -> (a : _) -> Var172 g a -> Tm172 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm172 (snoc172 g a) B -> Tm172 g (arr172 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm172 g (arr172 a B) -> Tm172 g a -> Tm172 g B)\n -> Tm172 g a\n\nvar172 : {g : _} -> {a : _} -> Var172 g a -> Tm172 g a\nvar172 = \\ x, tm, var172, lam, app => var172 _ _ x\n\nlam172 : {g : _} -> {a : _} -> {B : _} -> Tm172 (snoc172 g a) B -> Tm172 g (arr172 a B)\nlam172 = \\ t, tm, var172, lam172, app => lam172 _ _ _ (t tm var172 lam172 app)\n\napp172 : {g:_}->{a:_}->{B:_} -> Tm172 g (arr172 a B) -> Tm172 g a -> Tm172 g B\napp172 = \\ t, u, tm, var172, lam172, app172 => app172 _ _ _ (t tm var172 lam172 app172) (u tm var172 lam172 app172)\n\nv0172 : {g:_}->{a:_} -> Tm172 (snoc172 g a) a\nv0172 = var172 vz172\n\nv1172 : {g:_}->{a:_}-> {B:_}-> Tm172 (snoc172 (snoc172 g a) B) a\nv1172 = var172 (vs172 vz172)\n\nv2172 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm172 (snoc172 (snoc172 (snoc172 g a) B) C) a\nv2172 = var172 (vs172 (vs172 vz172))\n\nv3172 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm172 (snoc172 (snoc172 (snoc172 (snoc172 g a) B) C) D) a\nv3172 = var172 (vs172 (vs172 (vs172 vz172)))\n\nv4172 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm172 (snoc172 (snoc172 (snoc172 (snoc172 (snoc172 g a) B) C) D) E) a\nv4172 = var172 (vs172 (vs172 (vs172 (vs172 vz172))))\n\ntest172 : {g:_}-> {a:_} -> Tm172 g (arr172 (arr172 a a) (arr172 a a))\ntest172 = lam172 (lam172 (app172 v1172 (app172 v1172 (app172 v1172 (app172 v1172 (app172 v1172 (app172 v1172 v0172)))))))\nTy173 : Type\nTy173 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty173 : Ty173\nempty173 = \\ _, empty, _ => empty\n\narr173 : Ty173 -> Ty173 -> Ty173\narr173 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon173 : Type\nCon173 = (Con173 : Type)\n ->(nil : Con173)\n ->(snoc : Con173 -> Ty173 -> Con173)\n -> Con173\n\nnil173 : Con173\nnil173 = \\ con, nil173, snoc => nil173\n\nsnoc173 : Con173 -> Ty173 -> Con173\nsnoc173 = \\ g, a, con, nil173, snoc173 => snoc173 (g con nil173 snoc173) a\n\nVar173 : Con173 -> Ty173 -> Type\nVar173 = \\ g, a =>\n (Var173 : Con173 -> Ty173 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var173 (snoc173 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var173 g a -> Var173 (snoc173 g b) a)\n -> Var173 g a\n\nvz173 : {g : _}-> {a : _} -> Var173 (snoc173 g a) a\nvz173 = \\ var, vz173, vs => vz173 _ _\n\nvs173 : {g : _} -> {B : _} -> {a : _} -> Var173 g a -> Var173 (snoc173 g B) a\nvs173 = \\ x, var, vz173, vs173 => vs173 _ _ _ (x var vz173 vs173)\n\nTm173 : Con173 -> Ty173 -> Type\nTm173 = \\ g, a =>\n (Tm173 : Con173 -> Ty173 -> Type)\n -> (var : (g : _) -> (a : _) -> Var173 g a -> Tm173 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm173 (snoc173 g a) B -> Tm173 g (arr173 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm173 g (arr173 a B) -> Tm173 g a -> Tm173 g B)\n -> Tm173 g a\n\nvar173 : {g : _} -> {a : _} -> Var173 g a -> Tm173 g a\nvar173 = \\ x, tm, var173, lam, app => var173 _ _ x\n\nlam173 : {g : _} -> {a : _} -> {B : _} -> Tm173 (snoc173 g a) B -> Tm173 g (arr173 a B)\nlam173 = \\ t, tm, var173, lam173, app => lam173 _ _ _ (t tm var173 lam173 app)\n\napp173 : {g:_}->{a:_}->{B:_} -> Tm173 g (arr173 a B) -> Tm173 g a -> Tm173 g B\napp173 = \\ t, u, tm, var173, lam173, app173 => app173 _ _ _ (t tm var173 lam173 app173) (u tm var173 lam173 app173)\n\nv0173 : {g:_}->{a:_} -> Tm173 (snoc173 g a) a\nv0173 = var173 vz173\n\nv1173 : {g:_}->{a:_}-> {B:_}-> Tm173 (snoc173 (snoc173 g a) B) a\nv1173 = var173 (vs173 vz173)\n\nv2173 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm173 (snoc173 (snoc173 (snoc173 g a) B) C) a\nv2173 = var173 (vs173 (vs173 vz173))\n\nv3173 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm173 (snoc173 (snoc173 (snoc173 (snoc173 g a) B) C) D) a\nv3173 = var173 (vs173 (vs173 (vs173 vz173)))\n\nv4173 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm173 (snoc173 (snoc173 (snoc173 (snoc173 (snoc173 g a) B) C) D) E) a\nv4173 = var173 (vs173 (vs173 (vs173 (vs173 vz173))))\n\ntest173 : {g:_}-> {a:_} -> Tm173 g (arr173 (arr173 a a) (arr173 a a))\ntest173 = lam173 (lam173 (app173 v1173 (app173 v1173 (app173 v1173 (app173 v1173 (app173 v1173 (app173 v1173 v0173)))))))\nTy174 : Type\nTy174 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty174 : Ty174\nempty174 = \\ _, empty, _ => empty\n\narr174 : Ty174 -> Ty174 -> Ty174\narr174 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon174 : Type\nCon174 = (Con174 : Type)\n ->(nil : Con174)\n ->(snoc : Con174 -> Ty174 -> Con174)\n -> Con174\n\nnil174 : Con174\nnil174 = \\ con, nil174, snoc => nil174\n\nsnoc174 : Con174 -> Ty174 -> Con174\nsnoc174 = \\ g, a, con, nil174, snoc174 => snoc174 (g con nil174 snoc174) a\n\nVar174 : Con174 -> Ty174 -> Type\nVar174 = \\ g, a =>\n (Var174 : Con174 -> Ty174 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var174 (snoc174 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var174 g a -> Var174 (snoc174 g b) a)\n -> Var174 g a\n\nvz174 : {g : _}-> {a : _} -> Var174 (snoc174 g a) a\nvz174 = \\ var, vz174, vs => vz174 _ _\n\nvs174 : {g : _} -> {B : _} -> {a : _} -> Var174 g a -> Var174 (snoc174 g B) a\nvs174 = \\ x, var, vz174, vs174 => vs174 _ _ _ (x var vz174 vs174)\n\nTm174 : Con174 -> Ty174 -> Type\nTm174 = \\ g, a =>\n (Tm174 : Con174 -> Ty174 -> Type)\n -> (var : (g : _) -> (a : _) -> Var174 g a -> Tm174 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm174 (snoc174 g a) B -> Tm174 g (arr174 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm174 g (arr174 a B) -> Tm174 g a -> Tm174 g B)\n -> Tm174 g a\n\nvar174 : {g : _} -> {a : _} -> Var174 g a -> Tm174 g a\nvar174 = \\ x, tm, var174, lam, app => var174 _ _ x\n\nlam174 : {g : _} -> {a : _} -> {B : _} -> Tm174 (snoc174 g a) B -> Tm174 g (arr174 a B)\nlam174 = \\ t, tm, var174, lam174, app => lam174 _ _ _ (t tm var174 lam174 app)\n\napp174 : {g:_}->{a:_}->{B:_} -> Tm174 g (arr174 a B) -> Tm174 g a -> Tm174 g B\napp174 = \\ t, u, tm, var174, lam174, app174 => app174 _ _ _ (t tm var174 lam174 app174) (u tm var174 lam174 app174)\n\nv0174 : {g:_}->{a:_} -> Tm174 (snoc174 g a) a\nv0174 = var174 vz174\n\nv1174 : {g:_}->{a:_}-> {B:_}-> Tm174 (snoc174 (snoc174 g a) B) a\nv1174 = var174 (vs174 vz174)\n\nv2174 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm174 (snoc174 (snoc174 (snoc174 g a) B) C) a\nv2174 = var174 (vs174 (vs174 vz174))\n\nv3174 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm174 (snoc174 (snoc174 (snoc174 (snoc174 g a) B) C) D) a\nv3174 = var174 (vs174 (vs174 (vs174 vz174)))\n\nv4174 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm174 (snoc174 (snoc174 (snoc174 (snoc174 (snoc174 g a) B) C) D) E) a\nv4174 = var174 (vs174 (vs174 (vs174 (vs174 vz174))))\n\ntest174 : {g:_}-> {a:_} -> Tm174 g (arr174 (arr174 a a) (arr174 a a))\ntest174 = lam174 (lam174 (app174 v1174 (app174 v1174 (app174 v1174 (app174 v1174 (app174 v1174 (app174 v1174 v0174)))))))\nTy175 : Type\nTy175 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty175 : Ty175\nempty175 = \\ _, empty, _ => empty\n\narr175 : Ty175 -> Ty175 -> Ty175\narr175 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon175 : Type\nCon175 = (Con175 : Type)\n ->(nil : Con175)\n ->(snoc : Con175 -> Ty175 -> Con175)\n -> Con175\n\nnil175 : Con175\nnil175 = \\ con, nil175, snoc => nil175\n\nsnoc175 : Con175 -> Ty175 -> Con175\nsnoc175 = \\ g, a, con, nil175, snoc175 => snoc175 (g con nil175 snoc175) a\n\nVar175 : Con175 -> Ty175 -> Type\nVar175 = \\ g, a =>\n (Var175 : Con175 -> Ty175 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var175 (snoc175 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var175 g a -> Var175 (snoc175 g b) a)\n -> Var175 g a\n\nvz175 : {g : _}-> {a : _} -> Var175 (snoc175 g a) a\nvz175 = \\ var, vz175, vs => vz175 _ _\n\nvs175 : {g : _} -> {B : _} -> {a : _} -> Var175 g a -> Var175 (snoc175 g B) a\nvs175 = \\ x, var, vz175, vs175 => vs175 _ _ _ (x var vz175 vs175)\n\nTm175 : Con175 -> Ty175 -> Type\nTm175 = \\ g, a =>\n (Tm175 : Con175 -> Ty175 -> Type)\n -> (var : (g : _) -> (a : _) -> Var175 g a -> Tm175 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm175 (snoc175 g a) B -> Tm175 g (arr175 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm175 g (arr175 a B) -> Tm175 g a -> Tm175 g B)\n -> Tm175 g a\n\nvar175 : {g : _} -> {a : _} -> Var175 g a -> Tm175 g a\nvar175 = \\ x, tm, var175, lam, app => var175 _ _ x\n\nlam175 : {g : _} -> {a : _} -> {B : _} -> Tm175 (snoc175 g a) B -> Tm175 g (arr175 a B)\nlam175 = \\ t, tm, var175, lam175, app => lam175 _ _ _ (t tm var175 lam175 app)\n\napp175 : {g:_}->{a:_}->{B:_} -> Tm175 g (arr175 a B) -> Tm175 g a -> Tm175 g B\napp175 = \\ t, u, tm, var175, lam175, app175 => app175 _ _ _ (t tm var175 lam175 app175) (u tm var175 lam175 app175)\n\nv0175 : {g:_}->{a:_} -> Tm175 (snoc175 g a) a\nv0175 = var175 vz175\n\nv1175 : {g:_}->{a:_}-> {B:_}-> Tm175 (snoc175 (snoc175 g a) B) a\nv1175 = var175 (vs175 vz175)\n\nv2175 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm175 (snoc175 (snoc175 (snoc175 g a) B) C) a\nv2175 = var175 (vs175 (vs175 vz175))\n\nv3175 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm175 (snoc175 (snoc175 (snoc175 (snoc175 g a) B) C) D) a\nv3175 = var175 (vs175 (vs175 (vs175 vz175)))\n\nv4175 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm175 (snoc175 (snoc175 (snoc175 (snoc175 (snoc175 g a) B) C) D) E) a\nv4175 = var175 (vs175 (vs175 (vs175 (vs175 vz175))))\n\ntest175 : {g:_}-> {a:_} -> Tm175 g (arr175 (arr175 a a) (arr175 a a))\ntest175 = lam175 (lam175 (app175 v1175 (app175 v1175 (app175 v1175 (app175 v1175 (app175 v1175 (app175 v1175 v0175)))))))\nTy176 : Type\nTy176 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty176 : Ty176\nempty176 = \\ _, empty, _ => empty\n\narr176 : Ty176 -> Ty176 -> Ty176\narr176 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon176 : Type\nCon176 = (Con176 : Type)\n ->(nil : Con176)\n ->(snoc : Con176 -> Ty176 -> Con176)\n -> Con176\n\nnil176 : Con176\nnil176 = \\ con, nil176, snoc => nil176\n\nsnoc176 : Con176 -> Ty176 -> Con176\nsnoc176 = \\ g, a, con, nil176, snoc176 => snoc176 (g con nil176 snoc176) a\n\nVar176 : Con176 -> Ty176 -> Type\nVar176 = \\ g, a =>\n (Var176 : Con176 -> Ty176 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var176 (snoc176 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var176 g a -> Var176 (snoc176 g b) a)\n -> Var176 g a\n\nvz176 : {g : _}-> {a : _} -> Var176 (snoc176 g a) a\nvz176 = \\ var, vz176, vs => vz176 _ _\n\nvs176 : {g : _} -> {B : _} -> {a : _} -> Var176 g a -> Var176 (snoc176 g B) a\nvs176 = \\ x, var, vz176, vs176 => vs176 _ _ _ (x var vz176 vs176)\n\nTm176 : Con176 -> Ty176 -> Type\nTm176 = \\ g, a =>\n (Tm176 : Con176 -> Ty176 -> Type)\n -> (var : (g : _) -> (a : _) -> Var176 g a -> Tm176 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm176 (snoc176 g a) B -> Tm176 g (arr176 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm176 g (arr176 a B) -> Tm176 g a -> Tm176 g B)\n -> Tm176 g a\n\nvar176 : {g : _} -> {a : _} -> Var176 g a -> Tm176 g a\nvar176 = \\ x, tm, var176, lam, app => var176 _ _ x\n\nlam176 : {g : _} -> {a : _} -> {B : _} -> Tm176 (snoc176 g a) B -> Tm176 g (arr176 a B)\nlam176 = \\ t, tm, var176, lam176, app => lam176 _ _ _ (t tm var176 lam176 app)\n\napp176 : {g:_}->{a:_}->{B:_} -> Tm176 g (arr176 a B) -> Tm176 g a -> Tm176 g B\napp176 = \\ t, u, tm, var176, lam176, app176 => app176 _ _ _ (t tm var176 lam176 app176) (u tm var176 lam176 app176)\n\nv0176 : {g:_}->{a:_} -> Tm176 (snoc176 g a) a\nv0176 = var176 vz176\n\nv1176 : {g:_}->{a:_}-> {B:_}-> Tm176 (snoc176 (snoc176 g a) B) a\nv1176 = var176 (vs176 vz176)\n\nv2176 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm176 (snoc176 (snoc176 (snoc176 g a) B) C) a\nv2176 = var176 (vs176 (vs176 vz176))\n\nv3176 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm176 (snoc176 (snoc176 (snoc176 (snoc176 g a) B) C) D) a\nv3176 = var176 (vs176 (vs176 (vs176 vz176)))\n\nv4176 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm176 (snoc176 (snoc176 (snoc176 (snoc176 (snoc176 g a) B) C) D) E) a\nv4176 = var176 (vs176 (vs176 (vs176 (vs176 vz176))))\n\ntest176 : {g:_}-> {a:_} -> Tm176 g (arr176 (arr176 a a) (arr176 a a))\ntest176 = lam176 (lam176 (app176 v1176 (app176 v1176 (app176 v1176 (app176 v1176 (app176 v1176 (app176 v1176 v0176)))))))\nTy177 : Type\nTy177 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty177 : Ty177\nempty177 = \\ _, empty, _ => empty\n\narr177 : Ty177 -> Ty177 -> Ty177\narr177 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon177 : Type\nCon177 = (Con177 : Type)\n ->(nil : Con177)\n ->(snoc : Con177 -> Ty177 -> Con177)\n -> Con177\n\nnil177 : Con177\nnil177 = \\ con, nil177, snoc => nil177\n\nsnoc177 : Con177 -> Ty177 -> Con177\nsnoc177 = \\ g, a, con, nil177, snoc177 => snoc177 (g con nil177 snoc177) a\n\nVar177 : Con177 -> Ty177 -> Type\nVar177 = \\ g, a =>\n (Var177 : Con177 -> Ty177 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var177 (snoc177 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var177 g a -> Var177 (snoc177 g b) a)\n -> Var177 g a\n\nvz177 : {g : _}-> {a : _} -> Var177 (snoc177 g a) a\nvz177 = \\ var, vz177, vs => vz177 _ _\n\nvs177 : {g : _} -> {B : _} -> {a : _} -> Var177 g a -> Var177 (snoc177 g B) a\nvs177 = \\ x, var, vz177, vs177 => vs177 _ _ _ (x var vz177 vs177)\n\nTm177 : Con177 -> Ty177 -> Type\nTm177 = \\ g, a =>\n (Tm177 : Con177 -> Ty177 -> Type)\n -> (var : (g : _) -> (a : _) -> Var177 g a -> Tm177 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm177 (snoc177 g a) B -> Tm177 g (arr177 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm177 g (arr177 a B) -> Tm177 g a -> Tm177 g B)\n -> Tm177 g a\n\nvar177 : {g : _} -> {a : _} -> Var177 g a -> Tm177 g a\nvar177 = \\ x, tm, var177, lam, app => var177 _ _ x\n\nlam177 : {g : _} -> {a : _} -> {B : _} -> Tm177 (snoc177 g a) B -> Tm177 g (arr177 a B)\nlam177 = \\ t, tm, var177, lam177, app => lam177 _ _ _ (t tm var177 lam177 app)\n\napp177 : {g:_}->{a:_}->{B:_} -> Tm177 g (arr177 a B) -> Tm177 g a -> Tm177 g B\napp177 = \\ t, u, tm, var177, lam177, app177 => app177 _ _ _ (t tm var177 lam177 app177) (u tm var177 lam177 app177)\n\nv0177 : {g:_}->{a:_} -> Tm177 (snoc177 g a) a\nv0177 = var177 vz177\n\nv1177 : {g:_}->{a:_}-> {B:_}-> Tm177 (snoc177 (snoc177 g a) B) a\nv1177 = var177 (vs177 vz177)\n\nv2177 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm177 (snoc177 (snoc177 (snoc177 g a) B) C) a\nv2177 = var177 (vs177 (vs177 vz177))\n\nv3177 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm177 (snoc177 (snoc177 (snoc177 (snoc177 g a) B) C) D) a\nv3177 = var177 (vs177 (vs177 (vs177 vz177)))\n\nv4177 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm177 (snoc177 (snoc177 (snoc177 (snoc177 (snoc177 g a) B) C) D) E) a\nv4177 = var177 (vs177 (vs177 (vs177 (vs177 vz177))))\n\ntest177 : {g:_}-> {a:_} -> Tm177 g (arr177 (arr177 a a) (arr177 a a))\ntest177 = lam177 (lam177 (app177 v1177 (app177 v1177 (app177 v1177 (app177 v1177 (app177 v1177 (app177 v1177 v0177)))))))\nTy178 : Type\nTy178 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty178 : Ty178\nempty178 = \\ _, empty, _ => empty\n\narr178 : Ty178 -> Ty178 -> Ty178\narr178 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon178 : Type\nCon178 = (Con178 : Type)\n ->(nil : Con178)\n ->(snoc : Con178 -> Ty178 -> Con178)\n -> Con178\n\nnil178 : Con178\nnil178 = \\ con, nil178, snoc => nil178\n\nsnoc178 : Con178 -> Ty178 -> Con178\nsnoc178 = \\ g, a, con, nil178, snoc178 => snoc178 (g con nil178 snoc178) a\n\nVar178 : Con178 -> Ty178 -> Type\nVar178 = \\ g, a =>\n (Var178 : Con178 -> Ty178 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var178 (snoc178 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var178 g a -> Var178 (snoc178 g b) a)\n -> Var178 g a\n\nvz178 : {g : _}-> {a : _} -> Var178 (snoc178 g a) a\nvz178 = \\ var, vz178, vs => vz178 _ _\n\nvs178 : {g : _} -> {B : _} -> {a : _} -> Var178 g a -> Var178 (snoc178 g B) a\nvs178 = \\ x, var, vz178, vs178 => vs178 _ _ _ (x var vz178 vs178)\n\nTm178 : Con178 -> Ty178 -> Type\nTm178 = \\ g, a =>\n (Tm178 : Con178 -> Ty178 -> Type)\n -> (var : (g : _) -> (a : _) -> Var178 g a -> Tm178 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm178 (snoc178 g a) B -> Tm178 g (arr178 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm178 g (arr178 a B) -> Tm178 g a -> Tm178 g B)\n -> Tm178 g a\n\nvar178 : {g : _} -> {a : _} -> Var178 g a -> Tm178 g a\nvar178 = \\ x, tm, var178, lam, app => var178 _ _ x\n\nlam178 : {g : _} -> {a : _} -> {B : _} -> Tm178 (snoc178 g a) B -> Tm178 g (arr178 a B)\nlam178 = \\ t, tm, var178, lam178, app => lam178 _ _ _ (t tm var178 lam178 app)\n\napp178 : {g:_}->{a:_}->{B:_} -> Tm178 g (arr178 a B) -> Tm178 g a -> Tm178 g B\napp178 = \\ t, u, tm, var178, lam178, app178 => app178 _ _ _ (t tm var178 lam178 app178) (u tm var178 lam178 app178)\n\nv0178 : {g:_}->{a:_} -> Tm178 (snoc178 g a) a\nv0178 = var178 vz178\n\nv1178 : {g:_}->{a:_}-> {B:_}-> Tm178 (snoc178 (snoc178 g a) B) a\nv1178 = var178 (vs178 vz178)\n\nv2178 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm178 (snoc178 (snoc178 (snoc178 g a) B) C) a\nv2178 = var178 (vs178 (vs178 vz178))\n\nv3178 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm178 (snoc178 (snoc178 (snoc178 (snoc178 g a) B) C) D) a\nv3178 = var178 (vs178 (vs178 (vs178 vz178)))\n\nv4178 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm178 (snoc178 (snoc178 (snoc178 (snoc178 (snoc178 g a) B) C) D) E) a\nv4178 = var178 (vs178 (vs178 (vs178 (vs178 vz178))))\n\ntest178 : {g:_}-> {a:_} -> Tm178 g (arr178 (arr178 a a) (arr178 a a))\ntest178 = lam178 (lam178 (app178 v1178 (app178 v1178 (app178 v1178 (app178 v1178 (app178 v1178 (app178 v1178 v0178)))))))\nTy179 : Type\nTy179 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty179 : Ty179\nempty179 = \\ _, empty, _ => empty\n\narr179 : Ty179 -> Ty179 -> Ty179\narr179 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon179 : Type\nCon179 = (Con179 : Type)\n ->(nil : Con179)\n ->(snoc : Con179 -> Ty179 -> Con179)\n -> Con179\n\nnil179 : Con179\nnil179 = \\ con, nil179, snoc => nil179\n\nsnoc179 : Con179 -> Ty179 -> Con179\nsnoc179 = \\ g, a, con, nil179, snoc179 => snoc179 (g con nil179 snoc179) a\n\nVar179 : Con179 -> Ty179 -> Type\nVar179 = \\ g, a =>\n (Var179 : Con179 -> Ty179 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var179 (snoc179 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var179 g a -> Var179 (snoc179 g b) a)\n -> Var179 g a\n\nvz179 : {g : _}-> {a : _} -> Var179 (snoc179 g a) a\nvz179 = \\ var, vz179, vs => vz179 _ _\n\nvs179 : {g : _} -> {B : _} -> {a : _} -> Var179 g a -> Var179 (snoc179 g B) a\nvs179 = \\ x, var, vz179, vs179 => vs179 _ _ _ (x var vz179 vs179)\n\nTm179 : Con179 -> Ty179 -> Type\nTm179 = \\ g, a =>\n (Tm179 : Con179 -> Ty179 -> Type)\n -> (var : (g : _) -> (a : _) -> Var179 g a -> Tm179 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm179 (snoc179 g a) B -> Tm179 g (arr179 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm179 g (arr179 a B) -> Tm179 g a -> Tm179 g B)\n -> Tm179 g a\n\nvar179 : {g : _} -> {a : _} -> Var179 g a -> Tm179 g a\nvar179 = \\ x, tm, var179, lam, app => var179 _ _ x\n\nlam179 : {g : _} -> {a : _} -> {B : _} -> Tm179 (snoc179 g a) B -> Tm179 g (arr179 a B)\nlam179 = \\ t, tm, var179, lam179, app => lam179 _ _ _ (t tm var179 lam179 app)\n\napp179 : {g:_}->{a:_}->{B:_} -> Tm179 g (arr179 a B) -> Tm179 g a -> Tm179 g B\napp179 = \\ t, u, tm, var179, lam179, app179 => app179 _ _ _ (t tm var179 lam179 app179) (u tm var179 lam179 app179)\n\nv0179 : {g:_}->{a:_} -> Tm179 (snoc179 g a) a\nv0179 = var179 vz179\n\nv1179 : {g:_}->{a:_}-> {B:_}-> Tm179 (snoc179 (snoc179 g a) B) a\nv1179 = var179 (vs179 vz179)\n\nv2179 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm179 (snoc179 (snoc179 (snoc179 g a) B) C) a\nv2179 = var179 (vs179 (vs179 vz179))\n\nv3179 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm179 (snoc179 (snoc179 (snoc179 (snoc179 g a) B) C) D) a\nv3179 = var179 (vs179 (vs179 (vs179 vz179)))\n\nv4179 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm179 (snoc179 (snoc179 (snoc179 (snoc179 (snoc179 g a) B) C) D) E) a\nv4179 = var179 (vs179 (vs179 (vs179 (vs179 vz179))))\n\ntest179 : {g:_}-> {a:_} -> Tm179 g (arr179 (arr179 a a) (arr179 a a))\ntest179 = lam179 (lam179 (app179 v1179 (app179 v1179 (app179 v1179 (app179 v1179 (app179 v1179 (app179 v1179 v0179)))))))\nTy180 : Type\nTy180 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty180 : Ty180\nempty180 = \\ _, empty, _ => empty\n\narr180 : Ty180 -> Ty180 -> Ty180\narr180 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon180 : Type\nCon180 = (Con180 : Type)\n ->(nil : Con180)\n ->(snoc : Con180 -> Ty180 -> Con180)\n -> Con180\n\nnil180 : Con180\nnil180 = \\ con, nil180, snoc => nil180\n\nsnoc180 : Con180 -> Ty180 -> Con180\nsnoc180 = \\ g, a, con, nil180, snoc180 => snoc180 (g con nil180 snoc180) a\n\nVar180 : Con180 -> Ty180 -> Type\nVar180 = \\ g, a =>\n (Var180 : Con180 -> Ty180 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var180 (snoc180 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var180 g a -> Var180 (snoc180 g b) a)\n -> Var180 g a\n\nvz180 : {g : _}-> {a : _} -> Var180 (snoc180 g a) a\nvz180 = \\ var, vz180, vs => vz180 _ _\n\nvs180 : {g : _} -> {B : _} -> {a : _} -> Var180 g a -> Var180 (snoc180 g B) a\nvs180 = \\ x, var, vz180, vs180 => vs180 _ _ _ (x var vz180 vs180)\n\nTm180 : Con180 -> Ty180 -> Type\nTm180 = \\ g, a =>\n (Tm180 : Con180 -> Ty180 -> Type)\n -> (var : (g : _) -> (a : _) -> Var180 g a -> Tm180 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm180 (snoc180 g a) B -> Tm180 g (arr180 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm180 g (arr180 a B) -> Tm180 g a -> Tm180 g B)\n -> Tm180 g a\n\nvar180 : {g : _} -> {a : _} -> Var180 g a -> Tm180 g a\nvar180 = \\ x, tm, var180, lam, app => var180 _ _ x\n\nlam180 : {g : _} -> {a : _} -> {B : _} -> Tm180 (snoc180 g a) B -> Tm180 g (arr180 a B)\nlam180 = \\ t, tm, var180, lam180, app => lam180 _ _ _ (t tm var180 lam180 app)\n\napp180 : {g:_}->{a:_}->{B:_} -> Tm180 g (arr180 a B) -> Tm180 g a -> Tm180 g B\napp180 = \\ t, u, tm, var180, lam180, app180 => app180 _ _ _ (t tm var180 lam180 app180) (u tm var180 lam180 app180)\n\nv0180 : {g:_}->{a:_} -> Tm180 (snoc180 g a) a\nv0180 = var180 vz180\n\nv1180 : {g:_}->{a:_}-> {B:_}-> Tm180 (snoc180 (snoc180 g a) B) a\nv1180 = var180 (vs180 vz180)\n\nv2180 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm180 (snoc180 (snoc180 (snoc180 g a) B) C) a\nv2180 = var180 (vs180 (vs180 vz180))\n\nv3180 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm180 (snoc180 (snoc180 (snoc180 (snoc180 g a) B) C) D) a\nv3180 = var180 (vs180 (vs180 (vs180 vz180)))\n\nv4180 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm180 (snoc180 (snoc180 (snoc180 (snoc180 (snoc180 g a) B) C) D) E) a\nv4180 = var180 (vs180 (vs180 (vs180 (vs180 vz180))))\n\ntest180 : {g:_}-> {a:_} -> Tm180 g (arr180 (arr180 a a) (arr180 a a))\ntest180 = lam180 (lam180 (app180 v1180 (app180 v1180 (app180 v1180 (app180 v1180 (app180 v1180 (app180 v1180 v0180)))))))\nTy181 : Type\nTy181 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty181 : Ty181\nempty181 = \\ _, empty, _ => empty\n\narr181 : Ty181 -> Ty181 -> Ty181\narr181 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon181 : Type\nCon181 = (Con181 : Type)\n ->(nil : Con181)\n ->(snoc : Con181 -> Ty181 -> Con181)\n -> Con181\n\nnil181 : Con181\nnil181 = \\ con, nil181, snoc => nil181\n\nsnoc181 : Con181 -> Ty181 -> Con181\nsnoc181 = \\ g, a, con, nil181, snoc181 => snoc181 (g con nil181 snoc181) a\n\nVar181 : Con181 -> Ty181 -> Type\nVar181 = \\ g, a =>\n (Var181 : Con181 -> Ty181 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var181 (snoc181 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var181 g a -> Var181 (snoc181 g b) a)\n -> Var181 g a\n\nvz181 : {g : _}-> {a : _} -> Var181 (snoc181 g a) a\nvz181 = \\ var, vz181, vs => vz181 _ _\n\nvs181 : {g : _} -> {B : _} -> {a : _} -> Var181 g a -> Var181 (snoc181 g B) a\nvs181 = \\ x, var, vz181, vs181 => vs181 _ _ _ (x var vz181 vs181)\n\nTm181 : Con181 -> Ty181 -> Type\nTm181 = \\ g, a =>\n (Tm181 : Con181 -> Ty181 -> Type)\n -> (var : (g : _) -> (a : _) -> Var181 g a -> Tm181 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm181 (snoc181 g a) B -> Tm181 g (arr181 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm181 g (arr181 a B) -> Tm181 g a -> Tm181 g B)\n -> Tm181 g a\n\nvar181 : {g : _} -> {a : _} -> Var181 g a -> Tm181 g a\nvar181 = \\ x, tm, var181, lam, app => var181 _ _ x\n\nlam181 : {g : _} -> {a : _} -> {B : _} -> Tm181 (snoc181 g a) B -> Tm181 g (arr181 a B)\nlam181 = \\ t, tm, var181, lam181, app => lam181 _ _ _ (t tm var181 lam181 app)\n\napp181 : {g:_}->{a:_}->{B:_} -> Tm181 g (arr181 a B) -> Tm181 g a -> Tm181 g B\napp181 = \\ t, u, tm, var181, lam181, app181 => app181 _ _ _ (t tm var181 lam181 app181) (u tm var181 lam181 app181)\n\nv0181 : {g:_}->{a:_} -> Tm181 (snoc181 g a) a\nv0181 = var181 vz181\n\nv1181 : {g:_}->{a:_}-> {B:_}-> Tm181 (snoc181 (snoc181 g a) B) a\nv1181 = var181 (vs181 vz181)\n\nv2181 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm181 (snoc181 (snoc181 (snoc181 g a) B) C) a\nv2181 = var181 (vs181 (vs181 vz181))\n\nv3181 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm181 (snoc181 (snoc181 (snoc181 (snoc181 g a) B) C) D) a\nv3181 = var181 (vs181 (vs181 (vs181 vz181)))\n\nv4181 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm181 (snoc181 (snoc181 (snoc181 (snoc181 (snoc181 g a) B) C) D) E) a\nv4181 = var181 (vs181 (vs181 (vs181 (vs181 vz181))))\n\ntest181 : {g:_}-> {a:_} -> Tm181 g (arr181 (arr181 a a) (arr181 a a))\ntest181 = lam181 (lam181 (app181 v1181 (app181 v1181 (app181 v1181 (app181 v1181 (app181 v1181 (app181 v1181 v0181)))))))\nTy182 : Type\nTy182 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty182 : Ty182\nempty182 = \\ _, empty, _ => empty\n\narr182 : Ty182 -> Ty182 -> Ty182\narr182 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon182 : Type\nCon182 = (Con182 : Type)\n ->(nil : Con182)\n ->(snoc : Con182 -> Ty182 -> Con182)\n -> Con182\n\nnil182 : Con182\nnil182 = \\ con, nil182, snoc => nil182\n\nsnoc182 : Con182 -> Ty182 -> Con182\nsnoc182 = \\ g, a, con, nil182, snoc182 => snoc182 (g con nil182 snoc182) a\n\nVar182 : Con182 -> Ty182 -> Type\nVar182 = \\ g, a =>\n (Var182 : Con182 -> Ty182 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var182 (snoc182 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var182 g a -> Var182 (snoc182 g b) a)\n -> Var182 g a\n\nvz182 : {g : _}-> {a : _} -> Var182 (snoc182 g a) a\nvz182 = \\ var, vz182, vs => vz182 _ _\n\nvs182 : {g : _} -> {B : _} -> {a : _} -> Var182 g a -> Var182 (snoc182 g B) a\nvs182 = \\ x, var, vz182, vs182 => vs182 _ _ _ (x var vz182 vs182)\n\nTm182 : Con182 -> Ty182 -> Type\nTm182 = \\ g, a =>\n (Tm182 : Con182 -> Ty182 -> Type)\n -> (var : (g : _) -> (a : _) -> Var182 g a -> Tm182 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm182 (snoc182 g a) B -> Tm182 g (arr182 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm182 g (arr182 a B) -> Tm182 g a -> Tm182 g B)\n -> Tm182 g a\n\nvar182 : {g : _} -> {a : _} -> Var182 g a -> Tm182 g a\nvar182 = \\ x, tm, var182, lam, app => var182 _ _ x\n\nlam182 : {g : _} -> {a : _} -> {B : _} -> Tm182 (snoc182 g a) B -> Tm182 g (arr182 a B)\nlam182 = \\ t, tm, var182, lam182, app => lam182 _ _ _ (t tm var182 lam182 app)\n\napp182 : {g:_}->{a:_}->{B:_} -> Tm182 g (arr182 a B) -> Tm182 g a -> Tm182 g B\napp182 = \\ t, u, tm, var182, lam182, app182 => app182 _ _ _ (t tm var182 lam182 app182) (u tm var182 lam182 app182)\n\nv0182 : {g:_}->{a:_} -> Tm182 (snoc182 g a) a\nv0182 = var182 vz182\n\nv1182 : {g:_}->{a:_}-> {B:_}-> Tm182 (snoc182 (snoc182 g a) B) a\nv1182 = var182 (vs182 vz182)\n\nv2182 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm182 (snoc182 (snoc182 (snoc182 g a) B) C) a\nv2182 = var182 (vs182 (vs182 vz182))\n\nv3182 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm182 (snoc182 (snoc182 (snoc182 (snoc182 g a) B) C) D) a\nv3182 = var182 (vs182 (vs182 (vs182 vz182)))\n\nv4182 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm182 (snoc182 (snoc182 (snoc182 (snoc182 (snoc182 g a) B) C) D) E) a\nv4182 = var182 (vs182 (vs182 (vs182 (vs182 vz182))))\n\ntest182 : {g:_}-> {a:_} -> Tm182 g (arr182 (arr182 a a) (arr182 a a))\ntest182 = lam182 (lam182 (app182 v1182 (app182 v1182 (app182 v1182 (app182 v1182 (app182 v1182 (app182 v1182 v0182)))))))\nTy183 : Type\nTy183 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty183 : Ty183\nempty183 = \\ _, empty, _ => empty\n\narr183 : Ty183 -> Ty183 -> Ty183\narr183 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon183 : Type\nCon183 = (Con183 : Type)\n ->(nil : Con183)\n ->(snoc : Con183 -> Ty183 -> Con183)\n -> Con183\n\nnil183 : Con183\nnil183 = \\ con, nil183, snoc => nil183\n\nsnoc183 : Con183 -> Ty183 -> Con183\nsnoc183 = \\ g, a, con, nil183, snoc183 => snoc183 (g con nil183 snoc183) a\n\nVar183 : Con183 -> Ty183 -> Type\nVar183 = \\ g, a =>\n (Var183 : Con183 -> Ty183 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var183 (snoc183 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var183 g a -> Var183 (snoc183 g b) a)\n -> Var183 g a\n\nvz183 : {g : _}-> {a : _} -> Var183 (snoc183 g a) a\nvz183 = \\ var, vz183, vs => vz183 _ _\n\nvs183 : {g : _} -> {B : _} -> {a : _} -> Var183 g a -> Var183 (snoc183 g B) a\nvs183 = \\ x, var, vz183, vs183 => vs183 _ _ _ (x var vz183 vs183)\n\nTm183 : Con183 -> Ty183 -> Type\nTm183 = \\ g, a =>\n (Tm183 : Con183 -> Ty183 -> Type)\n -> (var : (g : _) -> (a : _) -> Var183 g a -> Tm183 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm183 (snoc183 g a) B -> Tm183 g (arr183 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm183 g (arr183 a B) -> Tm183 g a -> Tm183 g B)\n -> Tm183 g a\n\nvar183 : {g : _} -> {a : _} -> Var183 g a -> Tm183 g a\nvar183 = \\ x, tm, var183, lam, app => var183 _ _ x\n\nlam183 : {g : _} -> {a : _} -> {B : _} -> Tm183 (snoc183 g a) B -> Tm183 g (arr183 a B)\nlam183 = \\ t, tm, var183, lam183, app => lam183 _ _ _ (t tm var183 lam183 app)\n\napp183 : {g:_}->{a:_}->{B:_} -> Tm183 g (arr183 a B) -> Tm183 g a -> Tm183 g B\napp183 = \\ t, u, tm, var183, lam183, app183 => app183 _ _ _ (t tm var183 lam183 app183) (u tm var183 lam183 app183)\n\nv0183 : {g:_}->{a:_} -> Tm183 (snoc183 g a) a\nv0183 = var183 vz183\n\nv1183 : {g:_}->{a:_}-> {B:_}-> Tm183 (snoc183 (snoc183 g a) B) a\nv1183 = var183 (vs183 vz183)\n\nv2183 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm183 (snoc183 (snoc183 (snoc183 g a) B) C) a\nv2183 = var183 (vs183 (vs183 vz183))\n\nv3183 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm183 (snoc183 (snoc183 (snoc183 (snoc183 g a) B) C) D) a\nv3183 = var183 (vs183 (vs183 (vs183 vz183)))\n\nv4183 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm183 (snoc183 (snoc183 (snoc183 (snoc183 (snoc183 g a) B) C) D) E) a\nv4183 = var183 (vs183 (vs183 (vs183 (vs183 vz183))))\n\ntest183 : {g:_}-> {a:_} -> Tm183 g (arr183 (arr183 a a) (arr183 a a))\ntest183 = lam183 (lam183 (app183 v1183 (app183 v1183 (app183 v1183 (app183 v1183 (app183 v1183 (app183 v1183 v0183)))))))\nTy184 : Type\nTy184 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty184 : Ty184\nempty184 = \\ _, empty, _ => empty\n\narr184 : Ty184 -> Ty184 -> Ty184\narr184 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon184 : Type\nCon184 = (Con184 : Type)\n ->(nil : Con184)\n ->(snoc : Con184 -> Ty184 -> Con184)\n -> Con184\n\nnil184 : Con184\nnil184 = \\ con, nil184, snoc => nil184\n\nsnoc184 : Con184 -> Ty184 -> Con184\nsnoc184 = \\ g, a, con, nil184, snoc184 => snoc184 (g con nil184 snoc184) a\n\nVar184 : Con184 -> Ty184 -> Type\nVar184 = \\ g, a =>\n (Var184 : Con184 -> Ty184 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var184 (snoc184 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var184 g a -> Var184 (snoc184 g b) a)\n -> Var184 g a\n\nvz184 : {g : _}-> {a : _} -> Var184 (snoc184 g a) a\nvz184 = \\ var, vz184, vs => vz184 _ _\n\nvs184 : {g : _} -> {B : _} -> {a : _} -> Var184 g a -> Var184 (snoc184 g B) a\nvs184 = \\ x, var, vz184, vs184 => vs184 _ _ _ (x var vz184 vs184)\n\nTm184 : Con184 -> Ty184 -> Type\nTm184 = \\ g, a =>\n (Tm184 : Con184 -> Ty184 -> Type)\n -> (var : (g : _) -> (a : _) -> Var184 g a -> Tm184 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm184 (snoc184 g a) B -> Tm184 g (arr184 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm184 g (arr184 a B) -> Tm184 g a -> Tm184 g B)\n -> Tm184 g a\n\nvar184 : {g : _} -> {a : _} -> Var184 g a -> Tm184 g a\nvar184 = \\ x, tm, var184, lam, app => var184 _ _ x\n\nlam184 : {g : _} -> {a : _} -> {B : _} -> Tm184 (snoc184 g a) B -> Tm184 g (arr184 a B)\nlam184 = \\ t, tm, var184, lam184, app => lam184 _ _ _ (t tm var184 lam184 app)\n\napp184 : {g:_}->{a:_}->{B:_} -> Tm184 g (arr184 a B) -> Tm184 g a -> Tm184 g B\napp184 = \\ t, u, tm, var184, lam184, app184 => app184 _ _ _ (t tm var184 lam184 app184) (u tm var184 lam184 app184)\n\nv0184 : {g:_}->{a:_} -> Tm184 (snoc184 g a) a\nv0184 = var184 vz184\n\nv1184 : {g:_}->{a:_}-> {B:_}-> Tm184 (snoc184 (snoc184 g a) B) a\nv1184 = var184 (vs184 vz184)\n\nv2184 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm184 (snoc184 (snoc184 (snoc184 g a) B) C) a\nv2184 = var184 (vs184 (vs184 vz184))\n\nv3184 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm184 (snoc184 (snoc184 (snoc184 (snoc184 g a) B) C) D) a\nv3184 = var184 (vs184 (vs184 (vs184 vz184)))\n\nv4184 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm184 (snoc184 (snoc184 (snoc184 (snoc184 (snoc184 g a) B) C) D) E) a\nv4184 = var184 (vs184 (vs184 (vs184 (vs184 vz184))))\n\ntest184 : {g:_}-> {a:_} -> Tm184 g (arr184 (arr184 a a) (arr184 a a))\ntest184 = lam184 (lam184 (app184 v1184 (app184 v1184 (app184 v1184 (app184 v1184 (app184 v1184 (app184 v1184 v0184)))))))\nTy185 : Type\nTy185 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty185 : Ty185\nempty185 = \\ _, empty, _ => empty\n\narr185 : Ty185 -> Ty185 -> Ty185\narr185 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon185 : Type\nCon185 = (Con185 : Type)\n ->(nil : Con185)\n ->(snoc : Con185 -> Ty185 -> Con185)\n -> Con185\n\nnil185 : Con185\nnil185 = \\ con, nil185, snoc => nil185\n\nsnoc185 : Con185 -> Ty185 -> Con185\nsnoc185 = \\ g, a, con, nil185, snoc185 => snoc185 (g con nil185 snoc185) a\n\nVar185 : Con185 -> Ty185 -> Type\nVar185 = \\ g, a =>\n (Var185 : Con185 -> Ty185 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var185 (snoc185 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var185 g a -> Var185 (snoc185 g b) a)\n -> Var185 g a\n\nvz185 : {g : _}-> {a : _} -> Var185 (snoc185 g a) a\nvz185 = \\ var, vz185, vs => vz185 _ _\n\nvs185 : {g : _} -> {B : _} -> {a : _} -> Var185 g a -> Var185 (snoc185 g B) a\nvs185 = \\ x, var, vz185, vs185 => vs185 _ _ _ (x var vz185 vs185)\n\nTm185 : Con185 -> Ty185 -> Type\nTm185 = \\ g, a =>\n (Tm185 : Con185 -> Ty185 -> Type)\n -> (var : (g : _) -> (a : _) -> Var185 g a -> Tm185 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm185 (snoc185 g a) B -> Tm185 g (arr185 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm185 g (arr185 a B) -> Tm185 g a -> Tm185 g B)\n -> Tm185 g a\n\nvar185 : {g : _} -> {a : _} -> Var185 g a -> Tm185 g a\nvar185 = \\ x, tm, var185, lam, app => var185 _ _ x\n\nlam185 : {g : _} -> {a : _} -> {B : _} -> Tm185 (snoc185 g a) B -> Tm185 g (arr185 a B)\nlam185 = \\ t, tm, var185, lam185, app => lam185 _ _ _ (t tm var185 lam185 app)\n\napp185 : {g:_}->{a:_}->{B:_} -> Tm185 g (arr185 a B) -> Tm185 g a -> Tm185 g B\napp185 = \\ t, u, tm, var185, lam185, app185 => app185 _ _ _ (t tm var185 lam185 app185) (u tm var185 lam185 app185)\n\nv0185 : {g:_}->{a:_} -> Tm185 (snoc185 g a) a\nv0185 = var185 vz185\n\nv1185 : {g:_}->{a:_}-> {B:_}-> Tm185 (snoc185 (snoc185 g a) B) a\nv1185 = var185 (vs185 vz185)\n\nv2185 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm185 (snoc185 (snoc185 (snoc185 g a) B) C) a\nv2185 = var185 (vs185 (vs185 vz185))\n\nv3185 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm185 (snoc185 (snoc185 (snoc185 (snoc185 g a) B) C) D) a\nv3185 = var185 (vs185 (vs185 (vs185 vz185)))\n\nv4185 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm185 (snoc185 (snoc185 (snoc185 (snoc185 (snoc185 g a) B) C) D) E) a\nv4185 = var185 (vs185 (vs185 (vs185 (vs185 vz185))))\n\ntest185 : {g:_}-> {a:_} -> Tm185 g (arr185 (arr185 a a) (arr185 a a))\ntest185 = lam185 (lam185 (app185 v1185 (app185 v1185 (app185 v1185 (app185 v1185 (app185 v1185 (app185 v1185 v0185)))))))\nTy186 : Type\nTy186 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty186 : Ty186\nempty186 = \\ _, empty, _ => empty\n\narr186 : Ty186 -> Ty186 -> Ty186\narr186 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon186 : Type\nCon186 = (Con186 : Type)\n ->(nil : Con186)\n ->(snoc : Con186 -> Ty186 -> Con186)\n -> Con186\n\nnil186 : Con186\nnil186 = \\ con, nil186, snoc => nil186\n\nsnoc186 : Con186 -> Ty186 -> Con186\nsnoc186 = \\ g, a, con, nil186, snoc186 => snoc186 (g con nil186 snoc186) a\n\nVar186 : Con186 -> Ty186 -> Type\nVar186 = \\ g, a =>\n (Var186 : Con186 -> Ty186 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var186 (snoc186 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var186 g a -> Var186 (snoc186 g b) a)\n -> Var186 g a\n\nvz186 : {g : _}-> {a : _} -> Var186 (snoc186 g a) a\nvz186 = \\ var, vz186, vs => vz186 _ _\n\nvs186 : {g : _} -> {B : _} -> {a : _} -> Var186 g a -> Var186 (snoc186 g B) a\nvs186 = \\ x, var, vz186, vs186 => vs186 _ _ _ (x var vz186 vs186)\n\nTm186 : Con186 -> Ty186 -> Type\nTm186 = \\ g, a =>\n (Tm186 : Con186 -> Ty186 -> Type)\n -> (var : (g : _) -> (a : _) -> Var186 g a -> Tm186 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm186 (snoc186 g a) B -> Tm186 g (arr186 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm186 g (arr186 a B) -> Tm186 g a -> Tm186 g B)\n -> Tm186 g a\n\nvar186 : {g : _} -> {a : _} -> Var186 g a -> Tm186 g a\nvar186 = \\ x, tm, var186, lam, app => var186 _ _ x\n\nlam186 : {g : _} -> {a : _} -> {B : _} -> Tm186 (snoc186 g a) B -> Tm186 g (arr186 a B)\nlam186 = \\ t, tm, var186, lam186, app => lam186 _ _ _ (t tm var186 lam186 app)\n\napp186 : {g:_}->{a:_}->{B:_} -> Tm186 g (arr186 a B) -> Tm186 g a -> Tm186 g B\napp186 = \\ t, u, tm, var186, lam186, app186 => app186 _ _ _ (t tm var186 lam186 app186) (u tm var186 lam186 app186)\n\nv0186 : {g:_}->{a:_} -> Tm186 (snoc186 g a) a\nv0186 = var186 vz186\n\nv1186 : {g:_}->{a:_}-> {B:_}-> Tm186 (snoc186 (snoc186 g a) B) a\nv1186 = var186 (vs186 vz186)\n\nv2186 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm186 (snoc186 (snoc186 (snoc186 g a) B) C) a\nv2186 = var186 (vs186 (vs186 vz186))\n\nv3186 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm186 (snoc186 (snoc186 (snoc186 (snoc186 g a) B) C) D) a\nv3186 = var186 (vs186 (vs186 (vs186 vz186)))\n\nv4186 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm186 (snoc186 (snoc186 (snoc186 (snoc186 (snoc186 g a) B) C) D) E) a\nv4186 = var186 (vs186 (vs186 (vs186 (vs186 vz186))))\n\ntest186 : {g:_}-> {a:_} -> Tm186 g (arr186 (arr186 a a) (arr186 a a))\ntest186 = lam186 (lam186 (app186 v1186 (app186 v1186 (app186 v1186 (app186 v1186 (app186 v1186 (app186 v1186 v0186)))))))\nTy187 : Type\nTy187 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty187 : Ty187\nempty187 = \\ _, empty, _ => empty\n\narr187 : Ty187 -> Ty187 -> Ty187\narr187 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon187 : Type\nCon187 = (Con187 : Type)\n ->(nil : Con187)\n ->(snoc : Con187 -> Ty187 -> Con187)\n -> Con187\n\nnil187 : Con187\nnil187 = \\ con, nil187, snoc => nil187\n\nsnoc187 : Con187 -> Ty187 -> Con187\nsnoc187 = \\ g, a, con, nil187, snoc187 => snoc187 (g con nil187 snoc187) a\n\nVar187 : Con187 -> Ty187 -> Type\nVar187 = \\ g, a =>\n (Var187 : Con187 -> Ty187 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var187 (snoc187 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var187 g a -> Var187 (snoc187 g b) a)\n -> Var187 g a\n\nvz187 : {g : _}-> {a : _} -> Var187 (snoc187 g a) a\nvz187 = \\ var, vz187, vs => vz187 _ _\n\nvs187 : {g : _} -> {B : _} -> {a : _} -> Var187 g a -> Var187 (snoc187 g B) a\nvs187 = \\ x, var, vz187, vs187 => vs187 _ _ _ (x var vz187 vs187)\n\nTm187 : Con187 -> Ty187 -> Type\nTm187 = \\ g, a =>\n (Tm187 : Con187 -> Ty187 -> Type)\n -> (var : (g : _) -> (a : _) -> Var187 g a -> Tm187 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm187 (snoc187 g a) B -> Tm187 g (arr187 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm187 g (arr187 a B) -> Tm187 g a -> Tm187 g B)\n -> Tm187 g a\n\nvar187 : {g : _} -> {a : _} -> Var187 g a -> Tm187 g a\nvar187 = \\ x, tm, var187, lam, app => var187 _ _ x\n\nlam187 : {g : _} -> {a : _} -> {B : _} -> Tm187 (snoc187 g a) B -> Tm187 g (arr187 a B)\nlam187 = \\ t, tm, var187, lam187, app => lam187 _ _ _ (t tm var187 lam187 app)\n\napp187 : {g:_}->{a:_}->{B:_} -> Tm187 g (arr187 a B) -> Tm187 g a -> Tm187 g B\napp187 = \\ t, u, tm, var187, lam187, app187 => app187 _ _ _ (t tm var187 lam187 app187) (u tm var187 lam187 app187)\n\nv0187 : {g:_}->{a:_} -> Tm187 (snoc187 g a) a\nv0187 = var187 vz187\n\nv1187 : {g:_}->{a:_}-> {B:_}-> Tm187 (snoc187 (snoc187 g a) B) a\nv1187 = var187 (vs187 vz187)\n\nv2187 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm187 (snoc187 (snoc187 (snoc187 g a) B) C) a\nv2187 = var187 (vs187 (vs187 vz187))\n\nv3187 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm187 (snoc187 (snoc187 (snoc187 (snoc187 g a) B) C) D) a\nv3187 = var187 (vs187 (vs187 (vs187 vz187)))\n\nv4187 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm187 (snoc187 (snoc187 (snoc187 (snoc187 (snoc187 g a) B) C) D) E) a\nv4187 = var187 (vs187 (vs187 (vs187 (vs187 vz187))))\n\ntest187 : {g:_}-> {a:_} -> Tm187 g (arr187 (arr187 a a) (arr187 a a))\ntest187 = lam187 (lam187 (app187 v1187 (app187 v1187 (app187 v1187 (app187 v1187 (app187 v1187 (app187 v1187 v0187)))))))\nTy188 : Type\nTy188 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty188 : Ty188\nempty188 = \\ _, empty, _ => empty\n\narr188 : Ty188 -> Ty188 -> Ty188\narr188 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon188 : Type\nCon188 = (Con188 : Type)\n ->(nil : Con188)\n ->(snoc : Con188 -> Ty188 -> Con188)\n -> Con188\n\nnil188 : Con188\nnil188 = \\ con, nil188, snoc => nil188\n\nsnoc188 : Con188 -> Ty188 -> Con188\nsnoc188 = \\ g, a, con, nil188, snoc188 => snoc188 (g con nil188 snoc188) a\n\nVar188 : Con188 -> Ty188 -> Type\nVar188 = \\ g, a =>\n (Var188 : Con188 -> Ty188 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var188 (snoc188 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var188 g a -> Var188 (snoc188 g b) a)\n -> Var188 g a\n\nvz188 : {g : _}-> {a : _} -> Var188 (snoc188 g a) a\nvz188 = \\ var, vz188, vs => vz188 _ _\n\nvs188 : {g : _} -> {B : _} -> {a : _} -> Var188 g a -> Var188 (snoc188 g B) a\nvs188 = \\ x, var, vz188, vs188 => vs188 _ _ _ (x var vz188 vs188)\n\nTm188 : Con188 -> Ty188 -> Type\nTm188 = \\ g, a =>\n (Tm188 : Con188 -> Ty188 -> Type)\n -> (var : (g : _) -> (a : _) -> Var188 g a -> Tm188 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm188 (snoc188 g a) B -> Tm188 g (arr188 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm188 g (arr188 a B) -> Tm188 g a -> Tm188 g B)\n -> Tm188 g a\n\nvar188 : {g : _} -> {a : _} -> Var188 g a -> Tm188 g a\nvar188 = \\ x, tm, var188, lam, app => var188 _ _ x\n\nlam188 : {g : _} -> {a : _} -> {B : _} -> Tm188 (snoc188 g a) B -> Tm188 g (arr188 a B)\nlam188 = \\ t, tm, var188, lam188, app => lam188 _ _ _ (t tm var188 lam188 app)\n\napp188 : {g:_}->{a:_}->{B:_} -> Tm188 g (arr188 a B) -> Tm188 g a -> Tm188 g B\napp188 = \\ t, u, tm, var188, lam188, app188 => app188 _ _ _ (t tm var188 lam188 app188) (u tm var188 lam188 app188)\n\nv0188 : {g:_}->{a:_} -> Tm188 (snoc188 g a) a\nv0188 = var188 vz188\n\nv1188 : {g:_}->{a:_}-> {B:_}-> Tm188 (snoc188 (snoc188 g a) B) a\nv1188 = var188 (vs188 vz188)\n\nv2188 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm188 (snoc188 (snoc188 (snoc188 g a) B) C) a\nv2188 = var188 (vs188 (vs188 vz188))\n\nv3188 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm188 (snoc188 (snoc188 (snoc188 (snoc188 g a) B) C) D) a\nv3188 = var188 (vs188 (vs188 (vs188 vz188)))\n\nv4188 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm188 (snoc188 (snoc188 (snoc188 (snoc188 (snoc188 g a) B) C) D) E) a\nv4188 = var188 (vs188 (vs188 (vs188 (vs188 vz188))))\n\ntest188 : {g:_}-> {a:_} -> Tm188 g (arr188 (arr188 a a) (arr188 a a))\ntest188 = lam188 (lam188 (app188 v1188 (app188 v1188 (app188 v1188 (app188 v1188 (app188 v1188 (app188 v1188 v0188)))))))\nTy189 : Type\nTy189 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty189 : Ty189\nempty189 = \\ _, empty, _ => empty\n\narr189 : Ty189 -> Ty189 -> Ty189\narr189 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon189 : Type\nCon189 = (Con189 : Type)\n ->(nil : Con189)\n ->(snoc : Con189 -> Ty189 -> Con189)\n -> Con189\n\nnil189 : Con189\nnil189 = \\ con, nil189, snoc => nil189\n\nsnoc189 : Con189 -> Ty189 -> Con189\nsnoc189 = \\ g, a, con, nil189, snoc189 => snoc189 (g con nil189 snoc189) a\n\nVar189 : Con189 -> Ty189 -> Type\nVar189 = \\ g, a =>\n (Var189 : Con189 -> Ty189 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var189 (snoc189 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var189 g a -> Var189 (snoc189 g b) a)\n -> Var189 g a\n\nvz189 : {g : _}-> {a : _} -> Var189 (snoc189 g a) a\nvz189 = \\ var, vz189, vs => vz189 _ _\n\nvs189 : {g : _} -> {B : _} -> {a : _} -> Var189 g a -> Var189 (snoc189 g B) a\nvs189 = \\ x, var, vz189, vs189 => vs189 _ _ _ (x var vz189 vs189)\n\nTm189 : Con189 -> Ty189 -> Type\nTm189 = \\ g, a =>\n (Tm189 : Con189 -> Ty189 -> Type)\n -> (var : (g : _) -> (a : _) -> Var189 g a -> Tm189 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm189 (snoc189 g a) B -> Tm189 g (arr189 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm189 g (arr189 a B) -> Tm189 g a -> Tm189 g B)\n -> Tm189 g a\n\nvar189 : {g : _} -> {a : _} -> Var189 g a -> Tm189 g a\nvar189 = \\ x, tm, var189, lam, app => var189 _ _ x\n\nlam189 : {g : _} -> {a : _} -> {B : _} -> Tm189 (snoc189 g a) B -> Tm189 g (arr189 a B)\nlam189 = \\ t, tm, var189, lam189, app => lam189 _ _ _ (t tm var189 lam189 app)\n\napp189 : {g:_}->{a:_}->{B:_} -> Tm189 g (arr189 a B) -> Tm189 g a -> Tm189 g B\napp189 = \\ t, u, tm, var189, lam189, app189 => app189 _ _ _ (t tm var189 lam189 app189) (u tm var189 lam189 app189)\n\nv0189 : {g:_}->{a:_} -> Tm189 (snoc189 g a) a\nv0189 = var189 vz189\n\nv1189 : {g:_}->{a:_}-> {B:_}-> Tm189 (snoc189 (snoc189 g a) B) a\nv1189 = var189 (vs189 vz189)\n\nv2189 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm189 (snoc189 (snoc189 (snoc189 g a) B) C) a\nv2189 = var189 (vs189 (vs189 vz189))\n\nv3189 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm189 (snoc189 (snoc189 (snoc189 (snoc189 g a) B) C) D) a\nv3189 = var189 (vs189 (vs189 (vs189 vz189)))\n\nv4189 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm189 (snoc189 (snoc189 (snoc189 (snoc189 (snoc189 g a) B) C) D) E) a\nv4189 = var189 (vs189 (vs189 (vs189 (vs189 vz189))))\n\ntest189 : {g:_}-> {a:_} -> Tm189 g (arr189 (arr189 a a) (arr189 a a))\ntest189 = lam189 (lam189 (app189 v1189 (app189 v1189 (app189 v1189 (app189 v1189 (app189 v1189 (app189 v1189 v0189)))))))\nTy190 : Type\nTy190 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty190 : Ty190\nempty190 = \\ _, empty, _ => empty\n\narr190 : Ty190 -> Ty190 -> Ty190\narr190 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon190 : Type\nCon190 = (Con190 : Type)\n ->(nil : Con190)\n ->(snoc : Con190 -> Ty190 -> Con190)\n -> Con190\n\nnil190 : Con190\nnil190 = \\ con, nil190, snoc => nil190\n\nsnoc190 : Con190 -> Ty190 -> Con190\nsnoc190 = \\ g, a, con, nil190, snoc190 => snoc190 (g con nil190 snoc190) a\n\nVar190 : Con190 -> Ty190 -> Type\nVar190 = \\ g, a =>\n (Var190 : Con190 -> Ty190 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var190 (snoc190 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var190 g a -> Var190 (snoc190 g b) a)\n -> Var190 g a\n\nvz190 : {g : _}-> {a : _} -> Var190 (snoc190 g a) a\nvz190 = \\ var, vz190, vs => vz190 _ _\n\nvs190 : {g : _} -> {B : _} -> {a : _} -> Var190 g a -> Var190 (snoc190 g B) a\nvs190 = \\ x, var, vz190, vs190 => vs190 _ _ _ (x var vz190 vs190)\n\nTm190 : Con190 -> Ty190 -> Type\nTm190 = \\ g, a =>\n (Tm190 : Con190 -> Ty190 -> Type)\n -> (var : (g : _) -> (a : _) -> Var190 g a -> Tm190 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm190 (snoc190 g a) B -> Tm190 g (arr190 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm190 g (arr190 a B) -> Tm190 g a -> Tm190 g B)\n -> Tm190 g a\n\nvar190 : {g : _} -> {a : _} -> Var190 g a -> Tm190 g a\nvar190 = \\ x, tm, var190, lam, app => var190 _ _ x\n\nlam190 : {g : _} -> {a : _} -> {B : _} -> Tm190 (snoc190 g a) B -> Tm190 g (arr190 a B)\nlam190 = \\ t, tm, var190, lam190, app => lam190 _ _ _ (t tm var190 lam190 app)\n\napp190 : {g:_}->{a:_}->{B:_} -> Tm190 g (arr190 a B) -> Tm190 g a -> Tm190 g B\napp190 = \\ t, u, tm, var190, lam190, app190 => app190 _ _ _ (t tm var190 lam190 app190) (u tm var190 lam190 app190)\n\nv0190 : {g:_}->{a:_} -> Tm190 (snoc190 g a) a\nv0190 = var190 vz190\n\nv1190 : {g:_}->{a:_}-> {B:_}-> Tm190 (snoc190 (snoc190 g a) B) a\nv1190 = var190 (vs190 vz190)\n\nv2190 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm190 (snoc190 (snoc190 (snoc190 g a) B) C) a\nv2190 = var190 (vs190 (vs190 vz190))\n\nv3190 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm190 (snoc190 (snoc190 (snoc190 (snoc190 g a) B) C) D) a\nv3190 = var190 (vs190 (vs190 (vs190 vz190)))\n\nv4190 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm190 (snoc190 (snoc190 (snoc190 (snoc190 (snoc190 g a) B) C) D) E) a\nv4190 = var190 (vs190 (vs190 (vs190 (vs190 vz190))))\n\ntest190 : {g:_}-> {a:_} -> Tm190 g (arr190 (arr190 a a) (arr190 a a))\ntest190 = lam190 (lam190 (app190 v1190 (app190 v1190 (app190 v1190 (app190 v1190 (app190 v1190 (app190 v1190 v0190)))))))\nTy191 : Type\nTy191 = (Ty : Type)\n ->(empty : Ty)\n ->(arr : Ty -> Ty -> Ty)\n -> Ty\n\nempty191 : Ty191\nempty191 = \\ _, empty, _ => empty\n\narr191 : Ty191 -> Ty191 -> Ty191\narr191 = \\ a, b, ty, empty, arr => arr (a ty empty arr) (b ty empty arr)\n\nCon191 : Type\nCon191 = (Con191 : Type)\n ->(nil : Con191)\n ->(snoc : Con191 -> Ty191 -> Con191)\n -> Con191\n\nnil191 : Con191\nnil191 = \\ con, nil191, snoc => nil191\n\nsnoc191 : Con191 -> Ty191 -> Con191\nsnoc191 = \\ g, a, con, nil191, snoc191 => snoc191 (g con nil191 snoc191) a\n\nVar191 : Con191 -> Ty191 -> Type\nVar191 = \\ g, a =>\n (Var191 : Con191 -> Ty191 -> Type)\n -> (vz : (g : _)-> (a : _) -> Var191 (snoc191 g a) a)\n -> (vs : (g : _)-> (b : _) -> (a : _) -> Var191 g a -> Var191 (snoc191 g b) a)\n -> Var191 g a\n\nvz191 : {g : _}-> {a : _} -> Var191 (snoc191 g a) a\nvz191 = \\ var, vz191, vs => vz191 _ _\n\nvs191 : {g : _} -> {B : _} -> {a : _} -> Var191 g a -> Var191 (snoc191 g B) a\nvs191 = \\ x, var, vz191, vs191 => vs191 _ _ _ (x var vz191 vs191)\n\nTm191 : Con191 -> Ty191 -> Type\nTm191 = \\ g, a =>\n (Tm191 : Con191 -> Ty191 -> Type)\n -> (var : (g : _) -> (a : _) -> Var191 g a -> Tm191 g a)\n -> (lam : (g : _) -> (a : _) -> (B : _) -> Tm191 (snoc191 g a) B -> Tm191 g (arr191 a B))\n -> (app : (g : _) -> (a : _) -> (B : _) -> Tm191 g (arr191 a B) -> Tm191 g a -> Tm191 g B)\n -> Tm191 g a\n\nvar191 : {g : _} -> {a : _} -> Var191 g a -> Tm191 g a\nvar191 = \\ x, tm, var191, lam, app => var191 _ _ x\n\nlam191 : {g : _} -> {a : _} -> {B : _} -> Tm191 (snoc191 g a) B -> Tm191 g (arr191 a B)\nlam191 = \\ t, tm, var191, lam191, app => lam191 _ _ _ (t tm var191 lam191 app)\n\napp191 : {g:_}->{a:_}->{B:_} -> Tm191 g (arr191 a B) -> Tm191 g a -> Tm191 g B\napp191 = \\ t, u, tm, var191, lam191, app191 => app191 _ _ _ (t tm var191 lam191 app191) (u tm var191 lam191 app191)\n\nv0191 : {g:_}->{a:_} -> Tm191 (snoc191 g a) a\nv0191 = var191 vz191\n\nv1191 : {g:_}->{a:_}-> {B:_}-> Tm191 (snoc191 (snoc191 g a) B) a\nv1191 = var191 (vs191 vz191)\n\nv2191 : {g:_}-> {a:_}-> {B:_}-> {C:_} -> Tm191 (snoc191 (snoc191 (snoc191 g a) B) C) a\nv2191 = var191 (vs191 (vs191 vz191))\n\nv3191 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_} -> Tm191 (snoc191 (snoc191 (snoc191 (snoc191 g a) B) C) D) a\nv3191 = var191 (vs191 (vs191 (vs191 vz191)))\n\nv4191 : {g:_}-> {a:_}-> {B:_}-> {C:_}-> {D:_}-> {E:_}-> Tm191 (snoc191 (snoc191 (snoc191 (snoc191 (snoc191 g a) B) C) D) E) a\nv4191 = var191 (vs191 (vs191 (vs191 (vs191 vz191))))\n\ntest191 : {g:_}-> {a:_} -> Tm191 g (arr191 (arr191 a a) (arr191 a a))\ntest191 = lam191 (lam191 (app191 v1191 (app191 v1191 (app191 v1191 (app191 v1191 (app191 v1191 (app191 v1191 v0191)))))))\n", "meta": {"hexsha": "445b382705cf3a57fcfac64db9860eb2b448afbc", "size": 487992, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "bench/stlc_small10k.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_small10k.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_small10k.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": 35.794909411, "max_line_length": 125, "alphanum_fraction": 0.5243200708, "num_tokens": 216821, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8438951025545427, "lm_q2_score": 0.6548947425132315, "lm_q1q2_score": 0.5526624658956344}}
{"text": "module Data.OneOf\n\nimport public Data.List.Elem\nimport public Data.HList\n\n%default total\n\npublic export\ndata OneOf : List Type -> Type where\n Here : x -> OneOf (x :: xs)\n There : OneOf xs -> OneOf (x :: xs)\n\npublic export\nmake : Elem a as => a -> OneOf as\nmake x @{Here} = Here x\nmake x @{There _} = There (make x)\n\npublic export\nTypeAt : (as : List Type) -> OneOf as -> Type\nTypeAt (x :: _) (Here _) = x\nTypeAt (_ :: xs) (There x) = TypeAt xs x\n\npublic export\nEliminators : (as : List Type) -> (r : Type) -> Type\nEliminators xs r = HList (map (\\x => x -> r) xs)\n\npublic export\nget : (o : OneOf as) -> TypeAt as o\nget (Here x) = x\nget (There x) = get x\n\npublic export\nmatch : OneOf as -> Eliminators as r -> r\nmatch (Here x) (f :: _) = f x\nmatch (There x) (_ :: fs) = match x fs\n\npublic export\nextend : OneOf as -> OneOf (as ++ bs)\nextend (Here x) = Here x\nextend (There x) = There (extend x)\n", "meta": {"hexsha": "09f08fab38cacd35c3fafbdd2d9a57eac37c89c0", "size": 895, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/OneOf.idr", "max_stars_repo_name": "ywata/idris2-lsp", "max_stars_repo_head_hexsha": "95d7a016a6c93f76d3adf4c9ed01991f6d236eb6", "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/Data/OneOf.idr", "max_issues_repo_name": "ywata/idris2-lsp", "max_issues_repo_head_hexsha": "95d7a016a6c93f76d3adf4c9ed01991f6d236eb6", "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/OneOf.idr", "max_forks_repo_name": "ywata/idris2-lsp", "max_forks_repo_head_hexsha": "95d7a016a6c93f76d3adf4c9ed01991f6d236eb6", "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": 21.8292682927, "max_line_length": 52, "alphanum_fraction": 0.6234636872, "num_tokens": 300, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8056321983146848, "lm_q2_score": 0.685949467848392, "lm_q1q2_score": 0.5526229777154882}}
{"text": "import Data.List\nimport Data.List1\nimport Data.Vect\nimport Data.Vect.Elem\nimport Data.Vect.Extra\nimport Data.String.Parser\n\nimport System.File\n\nPos : Type\nPos = Vect 3 Integer\n\naddVec : Pos -> Pos -> Pos\naddVec [x1,y1,z1] [x2,y2,z2] = [x1+x2,y1+y2,z1+z2]\n\nminVec : Pos -> Pos -> Pos\nminVec [x1,y1,z1] [x2,y2,z2] = [x1-x2,y1-y2,z1-z2]\n\ndist : Pos -> Pos -> Integer\ndist p1 p2 = sum $ abs <$> minVec p1 p2\n\nrotateVecZ : Vect 3 Integer -> List (Vect 3 Integer)\nrotateVecZ [x,y,z] = [[x,y,z],[-y,x,z],[-x,-y,z],[y,-x,z]]\n\nrotateVec3 : Vect 3 Integer -> List (Vect 3 Integer)\nrotateVec3 [x,y,z] = join $ rotateVecZ <$> [[x,y,z],[-x,y,-z],[z,y,-x],[-z,y,x],[x,z,-y],[x,-z,y]]\n\nScanner : Type\nScanner = List Pos\n\nInput : Type\nInput = List1 Scanner\n\n\nposParser : Parser Pos\nposParser = do x <- integer\n skip $ char ','\n y <- integer\n skip $ char ','\n z <- integer\n pure [x, y, z]\n\nsome1 : Parser a -> Parser (List1 a)\nsome1 p = do Just s <- fromList <$> some p\n | Nothing => fail \"none\"\n pure s\n\nscannerParser : Parser Scanner\nscannerParser = token \"---\" *> token \"scanner\" *> lexeme natural *> token \"---\" *> some (posParser <* spaces)\n\nparser : Parser Input\nparser = some1 (scannerParser <* spaces)\n\n\nrotateScanner : Scanner -> List Scanner\nrotateScanner s = transpose $ rotateVec3 <$> s\n\nmoveRel : Scanner -> Pos -> Scanner\nmoveRel l p = map (addVec p) l\n\noverlaps : Scanner -> Scanner -> Pos -> Bool\noverlaps abs rels offset = (count ((flip elem) rels) $ (flip minVec) offset <$> abs) >= 12\n\noverlap : Scanner -> Scanner -> Maybe (Scanner, Pos)\noverlap abs rels = map (\\f => (union abs $ moveRel rels f, f)) $ find (overlaps abs rels) $ (join $ (\\a => minVec a <$> rels) <$> abs)\n\nanyOverlap : Scanner -> List Scanner -> Maybe (Scanner, Pos)\nanyOverlap abs [] = Nothing\nanyOverlap abs (x :: xs) = overlap abs x <|> anyOverlap abs xs\n\nfindOverlap : Scanner -> List (List Scanner) -> Maybe (Scanner, Pos, List (List Scanner))\nfindOverlap abs [] = Nothing\nfindOverlap abs (rel :: rels) = case anyOverlap abs rel of\n Nothing => do (abs, offset, rels) <- findOverlap abs rels\n pure (abs, offset, rel :: rels)\n (Just (abs, offset)) => Just (abs, offset, rels)\n\noverlapall : Scanner -> List (List Scanner) -> IO (Maybe (Scanner, List Pos))\noverlapall abs [] = pure $ Just (abs, [])\noverlapall abs rels = do Just (abs, offset, rels) <- pure $ findOverlap abs rels\n | Nothing => pure Nothing\n putStrLn $ (show $ length rels) ++ \"scanners left\"\n Just (all, offsets) <- overlapall abs rels\n | Nothing => pure Nothing\n pure $ Just (all, offset :: offsets)\n\npart1and2 : Input -> IO String\npart1and2 (x ::: xs) = do Just (bs, offsets) <- overlapall x (rotateScanner <$> xs)\n | Nothing => pure \"no overlap\"\n putStrLn $ show $ length bs\n pure $ show $ foldl max 0 $ join $ (\\o => dist o <$> offsets) <$> offsets\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 part1and2 a >>= putStrLn\n\n", "meta": {"hexsha": "619237c21ccf1832e8b4d5b114b1706d21e4b8eb", "size": 3435, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "19/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": "19/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": "19/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": 34.35, "max_line_length": 134, "alphanum_fraction": 0.5586608443, "num_tokens": 933, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.877476793890012, "lm_q2_score": 0.6297746074044135, "lm_q1q2_score": 0.5526126033785658}}
{"text": "module Decidable.Order\n\nimport Decidable.Decidable\nimport Decidable.Equality\nimport Data.Fin\nimport Data.Fun\nimport Data.Rel\n\n%hide Prelude.Equal\n\n--------------------------------------------------------------------------------\n-- Utility Lemmas\n--------------------------------------------------------------------------------\n\n--------------------------------------------------------------------------------\n-- Preorders, Posets, total Orders, Equivalencies, Congruencies\n--------------------------------------------------------------------------------\n\npublic export\ninterface Preorder t (po : t -> t -> Type) where\n total transitive : (a : t) -> (b : t) -> (c : t) -> po a b -> po b c -> po a c\n total reflexive : (a : t) -> po a a\n\npublic export\ninterface (Preorder t po) => Poset t (po : t -> t -> Type) where\n total antisymmetric : (a : t) -> (b : t) -> po a b -> po b a -> a = b\n\npublic export\ninterface (Poset t to) => Ordered t (to : t -> t -> Type) where\n total order : (a : t) -> (b : t) -> Either (to a b) (to b a)\n\npublic export\ninterface (Preorder t eq) => Equivalence t (eq : t -> t -> Type) where\n total symmetric : (a : t) -> (b : t) -> eq a b -> eq b a\n\npublic export\ninterface (Equivalence t eq) => Congruence t (f : t -> t) (eq : t -> t -> Type) where\n total congruent : (a : t) ->\n (b : t) ->\n eq a b ->\n eq (f a) (f b)\n\npublic export\nminimum : (Ordered t to) => t -> t -> t\nminimum {to} x y with (order {to} x y)\n minimum {to} x y | Left _ = x\n minimum {to} x y | Right _ = y\n\npublic export\nmaximum : (Ordered t to) => t -> t -> t\nmaximum {to} x y with (order {to} x y)\n maximum {to} x y | Left _ = y\n maximum {to} x y | Right _ = x\n\n--------------------------------------------------------------------------------\n-- Syntactic equivalence (=)\n--------------------------------------------------------------------------------\n\npublic export\nimplementation Preorder t Equal where\n transitive a b c l r = trans l r\n reflexive a = Refl\n\npublic export\nimplementation Equivalence t Equal where\n symmetric a b prf = sym prf\n\npublic export\nimplementation Congruence t f Equal where\n congruent a b eq = cong f eq\n", "meta": {"hexsha": "3fceb31adb3697cf4e0e7fb5143a1d61df798a25", "size": 2197, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "idris2/libs/base/Decidable/Order.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/Decidable/Order.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/Decidable/Order.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.9436619718, "max_line_length": 85, "alphanum_fraction": 0.4710969504, "num_tokens": 557, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8175744761936438, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.5524878897083545}}
{"text": "module Quantities.SIPrefixes\n\nimport Quantities.Core\n\n%default total\n%access public export\n\nmakePrefix : Integer -> Unit q -> Unit q\nmakePrefix i (MkUnit e us) = MkUnit (e+i) us\n\n\n-- List of prefixes from\n-- http://en.wikipedia.org/wiki/Metric_prefix\n\nyotta : Unit q -> Unit q\nyotta = makePrefix 24\n\nzetta : Unit q -> Unit q\nzetta = makePrefix 21\n\nexa : Unit q -> Unit q\nexa = makePrefix 18\n\npeta : Unit q -> Unit q\npeta = makePrefix 15\n\ntera : Unit q -> Unit q\ntera = makePrefix 12\n\ngiga : Unit q -> Unit q\ngiga = makePrefix 9\nG : Unit q -> Unit q\nG = giga\n\nmega : Unit q -> Unit q\nmega = makePrefix 6\nM : Unit q -> Unit q\nM = mega\n\nkilo : Unit q -> Unit q\nkilo = makePrefix 3\nk : Unit q -> Unit q\nk = kilo\n\nhecto : Unit q -> Unit q\nhecto = makePrefix 2\n\ndeca : Unit q -> Unit q\ndeca = makePrefix 1\nda : Unit q -> Unit q\nda = deca\n\n-- ################## --\n\ndeci : Unit q -> Unit q\ndeci = makePrefix (-1)\n\ncenti : Unit q -> Unit q\ncenti = makePrefix (-2)\n\nmilli : Unit q -> Unit q\nmilli = makePrefix (-3)\n\nmicro : Unit q -> Unit q\nmicro = makePrefix (-6)\n\nnano : Unit q -> Unit q\nnano = makePrefix (-9)\n\npico : Unit q -> Unit q\npico = makePrefix (-12)\n\nfemto : Unit q -> Unit q\nfemto = makePrefix (-15)\n\natto : Unit q -> Unit q\natto = makePrefix (-18)\n\nzepto : Unit q -> Unit q\nzepto = makePrefix (-21)\n\nyocto : Unit q -> Unit q\nyocto = makePrefix (-24)\n", "meta": {"hexsha": "ff2e926c0a3b5f7fa92be03ee18a41d428baed46", "size": 1355, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Quantities/SIPrefixes.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/SIPrefixes.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/SIPrefixes.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": 16.130952381, "max_line_length": 45, "alphanum_fraction": 0.6332103321, "num_tokens": 460, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.782662489091802, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.552391466650642}}
{"text": "module TreeQ\r\n\r\n%default total\r\n%access public export\r\n\r\n||| A tree structure for combining queries, perhaps slightly less expressive\r\n||| than a free monad, but easier to prove total, etc. I say less expressive,\r\n||| because I do not believe it is a monad, whereas my applicative instance\r\n||| seems pretty solid. Moreover, it has a nice monoid instance, given a monoid\r\n||| on the type it is parameterized over (but requiring no effort from the query\r\n||| GADT). I have also provided a generalized semigroup operation based on\r\n||| pairing items together. However, regrettable, it does not seem to be\r\n||| foldable, since some of it's data is based on a future promise and isn't\r\n||| available yet. This means it is not traversable. However, I think this may\r\n||| be okay: ultimately the point of traversing is to push the query to the\r\n||| outside until we're ready to run it, so the traverse instances of list,\r\n||| maybe and either should serve us well enough, since we just barely make the\r\n||| minimum requirement (applicative) to play ball with them.\r\ndata QryTree : (Type -> Type) -> Type -> Type where\r\n ||| Pure for monad/applicative: lift a plain value into the tree\r\n PureLeaf : a -> QryTree q a\r\n ||| Lift a query into the tree\r\n LiftLeaf : q i -> (i -> a) -> QryTree q a\r\n ||| Gives us a monoid operation\r\n Branch : QryTree q a -> QryTree q b -> ((a, b) -> c) -> QryTree q c\r\n\r\nliftQ : q a -> QryTree q a\r\nliftQ qry = LiftLeaf qry id\r\n\r\ninfixr 5 ^+^\r\n\r\n||| Generalized semigroup operation\r\n(^+^) : QryTree q a -> QryTree q b -> QryTree q (a, b)\r\nq ^+^ r = Branch q r id\r\n\r\nSemigroup a => Semigroup (QryTree q a) where\r\n q <+> r = Branch q r (uncurry (<+>))\r\n\r\nMonoid a => Monoid (QryTree q a) where\r\n neutral = PureLeaf neutral\r\n\r\nFunctor q => Functor (QryTree q) where\r\n map f (PureLeaf x) = PureLeaf (f x)\r\n map f (LiftLeaf q handle) = LiftLeaf q (f . handle)\r\n map f (Branch q r handle) = Branch q r (f . handle)\r\n\r\n-- A foldable instance does not seem possible. You could start easily enough:\r\n-- Foldable (QryTree q) where\r\n-- foldr func init (PureLeaf x) = func x init\r\n-- But where would you go from there?\r\n-- foldr func init (LiftLeaf x f) = ?foldable_moldable_2\r\n-- foldr func init (Branch x y f) = ?foldable_moldable_3\r\n-- The data you have promised right now is stuck in the future...\r\n\r\n||| The s combinator, with a dash of uncurrying\r\ns' : (a -> (b -> c)) -> (d -> b) -> (a, d) -> c\r\ns' f g (x, y) = f x (g y)\r\n\r\n||| I am not any good at equality proofs in Idris. However, I am not content to\r\n||| rest uncertain about whether this applicative instance is lawful! So here\r\n||| you go: back to geometry class: a long-hand proof, in the comments!\r\n|||\r\n||| identity: pure id <*> v = v\r\n||| PureLeaf id <*> v = v\r\n||| | PureLeaf id <*> PureLeaf x = v\r\n||| -> PureLeaf (id x) = v\r\n||| -> PureLeaf x = v\r\n||| -> v = v\r\n||| -> QED\r\n||| | PureLeaf id <*> LiftLeaf q g = v\r\n||| -> LiftLeaf q (id . g) = v\r\n||| -> LiftLeaf q g = v\r\n||| -> v = v\r\n||| -> QED\r\n||| | PureLeaf id <*> Branch q r g = v\r\n||| -> Branch q r (id . g) = v\r\n||| -> Branch q r g = v\r\n||| -> v = v\r\n||| -> QED\r\n||| -> QED\r\n|||\r\n||| composition: pure (.) <*> u <*> v <*> w = u <*> (v <*> w)\r\n||| PureLeaf (.) <*> u <*> v <*> w = u <*> (v <*> w)\r\n||| PureLeaf (\\f g x => f (g x)) <*> u <*> v <*> w = u <*> (v <*> w)\r\n||| | PureLeaf (.) <*> PureLeaf u' <*> v <*> w = PureLeaf u' <*> (v <*> w)\r\n||| | PureLeaf (u' .) <*> PureLeaf v' <*> w = PureLeaf u' <*> (PureLeaf v' <*> w)\r\n||| -> PureLeaf (u' . v') <*> w = PureLeaf u' <*> (PureLeaf v' <*> w)\r\n||| | PureLeaf (\\x => u' (v' x)) <*> PureLeaf w' = PureLeaf u' <*> (PureLeaf v' <*> PureLeaf w')\r\n||| -> PureLeaf (u' (v' w')) = PureLeaf u' <*> PureLeaf (v' w')\r\n||| -> PureLeaf (u' (v' w')) = PureLeaf (u' (v' w'))\r\n||| -> QED\r\n||| | PureLeaf (u' . v') <*> LiftLeaf q w' = PureLeaf u' <*> (PureLeaf v' <*> LiftLeaf q w')\r\n||| -> LiftLeaf q ((u' . v') . w') = PureLeaf u' <*> (LiftLeaf q (v' . w'))\r\n||| -> LiftLeaf q (u' . (v' . w')) = LiftLeaf q (u' . (v' . w'))\r\n||| -> QED\r\n||| | PureLeaf (u' . v') <*> Branch q r w' = PureLeaf u' <*> (PureLeaf v' <*> Branch q r w')\r\n||| -> Branch q r ((u' . v') . w') = PureLeaf u' <*> (Branch q r (v' . w'))\r\n||| -> Branch q r (u' . (v' . w')) = Branch q r (u' . (v' . w'))\r\n||| -> QED\r\n||| -> QED\r\n||| | PureLeaf (u' .) <*> LiftLeaf q v' <*> w = PureLeaf u' <*> (LiftLeaf q v' <*> w)\r\n||| -> LiftLeaf q ((u' .) . v') <*> w = PureLeaf u' <*> (LiftLeaf q v' <*> w)\r\n||| -> LiftLeaf q ((\\g x => u' (g x)) . v') <*> w = PureLeaf u' <*> (LiftLeaf q v' <*> w)\r\n||| -> LiftLeaf q (\\y => (\\g x => u' (g x)) (v' y)) <*> w = PureLeaf u' <*> (LiftLeaf q v' <*> w)\r\n||| -> LiftLeaf q (\\y x => u' (v' y x)) <*> w = PureLeaf u' <*> (LiftLeaf q v' <*> w)\r\n||| | LiftLeaf q (\\y x => u' (v' y x)) <*> PureLeaf w' = PureLeaf u' <*> (LiftLeaf q v' <*> PureLeaf w')\r\n||| -> LiftLeaf q (\\z => (\\y x => u' (v' y x)) z w') = PureLeaf u' <*> (LiftLeaf q (\\y => v' y w'))\r\n||| -> LiftLeaf q (\\z => (\\x => u' (v' z x)) w') = LiftLeaf q (\\z => u' ((\\y => v' y w') z))\r\n||| -> LiftLeaf q (\\z => u' (v' z w')) = LiftLeaf q (\\z => u' (v' z w'))\r\n||| -> QED\r\n||| | LiftLeaf q (\\y x => u' (v' y x)) <*> LiftLeaf r w' = PureLeaf u' <*> (LiftLeaf q v' <*> LiftLeaf r w')\r\n||| -> Brand (LiftLeaf q id) (LiftLeaf r id) (s' (\\y x => u' (v' y x)) w') = PureLeaf u' <*> (Branch (LiftLeaf q id) (LiftLeaf r id) (s' v' w'))\r\n||| -> Brand (LiftLeaf q id) (LiftLeaf r id) (\\(a, b) => (\\y x => u' (v' y x)) a (w' b)) = Branch (LiftLeaf q id) (LiftLeaf r id) (u' . s' v' w')\r\n||| -> ... (\\(a, b) => (\\x => u' (v' a x)) (w' b)) = ... (u' . s' v' w')\r\n||| -> ... (\\(a, b) => u' (v' a (w' b))) = ... (u' . s' v' w')\r\n||| -> ... (\\(a, b) => u' (s' v' w' (a, b))) = ... (u' . s' v' w')\r\n||| -> ... (\\(a, b) => (u' . s' v' w') (a, b)) = ... (u' . s' v' w')\r\n||| -> ... (u' . s' v' w') = ... (u' . s' v' w')\r\n||| -> QED\r\n||| | LiftLeaf q (\\y x => u' (v' y x)) <*> Branch r s w' = PureLeaf u' <*> (LiftLeaf q v' <*> Branch r s w')\r\n||| -> Brand (LiftLeaf q id) (Breanch r s id) (s' (\\y x => u' (v' y x)) w') = PureLeaf u' <*> (Branch (LiftLeaf q id) (Breanch r s id) (s' v' w'))\r\n||| -> Brand (LiftLeaf q id) (Breanch r s id) (\\(a, b) => (\\y x => u' (v' y x)) a (w' b)) = Branch (LiftLeaf q id) (Breanch r s id) (u' . s' v' w')\r\n||| -> ... (\\(a, b) => (\\x => u' (v' a x)) (w' b)) = ... (u' . s' v' w')\r\n||| -> ... (\\(a, b) => u' (v' a (w' b))) = ... (u' . s' v' w')\r\n||| -> ... (\\(a, b) => u' (s' v' w' (a, b))) = ... (u' . s' v' w')\r\n||| -> ... (\\(a, b) => (u' . s' v' w') (a, b)) = ... (u' . s' v' w')\r\n||| -> ... (u' . s' v' w') = ... (u' . s' v' w')\r\n||| -> QED\r\n||| -> QED\r\n||| Suddenly I do the math and realized that I'm only 2/9th's done... perhaps\r\n||| there is a better way to approach this than doing it late at night. The\r\n||| results so far are very promising in that it seems that the same laborious\r\n||| technique should continue to work. Perhaps this could be reduced more easily\r\n||| by introducing some lemmas. Or by figuring out how to do it with Idris. Or\r\n||| by researching if it has been done before. Or one could argue this way: we\r\n||| have at this point really encountered all the scenarios. Things work right\r\n||| if pure comes before, or after; it cancels out. LiftLeaf and Branch\r\n||| fundamentally have the same semanticcs, and the proof above regarding the\r\n||| semantics of the S-combinator seem conclusive for all cases involving them.\r\n||| It seems that for a proof of this length, it is foolhardy to continue\r\n||| without computer assistance and checking. My sense that this is not a bogus\r\n||| implementation of applicative is quite high at this point. I leave it as an\r\n||| exercise for the reader to complete, where by \"the reader\" I mean \"me, I\r\n||| hope, at some later date.\"\r\n|||\r\n||| homomorphism: pure f <*> pure x = pure (f x)\r\n||| PureLeaf f <*> PureLeaf x = PureLeaf (f x)\r\n||| -> QED\r\n|||\r\n||| interchange: u <*> pure y = pure ($ y) <*> u\r\n||| u <*> PureLeaf y = PureLeaf ($ y) <*> u\r\n||| | PureLeaf f <*> PureLeaf y = PureLeaf ($ y) <*> PureLeaf f\r\n||| -> PureLeaf (f y) = PureLeaf (f $ y)\r\n||| -> PureLeaf (f y) = PureLeaf (f y)\r\n||| -> QED\r\n||| | LiftLeaf q f <*> PureLeaf y = PureLeaf ($ y) <*> LiftLeaf q f\r\n||| -> LiftLeaf q f <*> PureLeaf y = PureLeaf ($ y) <*> LiftLeaf q f\r\n||| -> LiftLeaf q (\\z => f z y) = LiftLeaf q ((\\x => \\g => g x) y . f)\r\n||| -> LiftLeaf q (\\z => f z y) = LiftLeaf q ((\\g => g y) . f)\r\n||| -> LiftLeaf q (\\z => f z y) = LiftLeaf q (\\z => (\\g => g y) (f z))\r\n||| -> LiftLeaf q (\\z => f z y) = LiftLeaf q (\\z => f z y)\r\n||| -> QED\r\n||| | Branch q r f <*> PureLeaf y = PureLeaf ($ y) <*> Branch q r f\r\n||| -> Branch q r f <*> PureLeaf y = PureLeaf ($ y) <*> Branch q r f\r\n||| -> Branch q r (\\z => f z y) = Branch q r ((\\x => \\g => g x) y . f)\r\n||| -> Branch q r (\\z => f z y) = Branch q r ((\\g => g y) . f)\r\n||| -> Branch q r (\\z => f z y) = Branch q r (\\z => (\\g => g y) (f z))\r\n||| -> Branch q r (\\z => f z y) = Branch q r (\\z => f z y)\r\n||| -> QED\r\n||| -> QED\r\n|||\r\n||| These are the four properties I found needful to prove based on my\r\n||| understanding of Haskell's Control.Applicative documentation.\r\nFunctor q => Applicative (QryTree q) where\r\n pure = PureLeaf\r\n (PureLeaf f) <*> (PureLeaf x) =\r\n PureLeaf (f x)\r\n (PureLeaf f) <*> (LiftLeaf q g) =\r\n LiftLeaf q (f . g)\r\n (PureLeaf f) <*> (Branch q r g) =\r\n Branch q r (f . g)\r\n (LiftLeaf q f) <*> (PureLeaf x) =\r\n LiftLeaf q (\\y => f y x)\r\n (LiftLeaf q f) <*> (LiftLeaf r g) =\r\n Branch (LiftLeaf q id) (LiftLeaf r id) $ s' f g\r\n (LiftLeaf q f) <*> (Branch r s g) =\r\n Branch (LiftLeaf q id) (Branch r s id) $ s' f g\r\n (Branch q r f) <*> (PureLeaf x) =\r\n Branch q r (\\y => f y x)\r\n (Branch q r f) <*> (LiftLeaf s g) =\r\n Branch (Branch q r id) (LiftLeaf s id) $ s' f g\r\n (Branch q r f) <*> (Branch s t g) =\r\n Branch (Branch q r id) (Branch s t id) $ s' f g\r\n\r\n-- How would you implement a monad?\r\n-- Functor q => Monad (QryTree q) where\r\n-- The first case would be easy:\r\n-- (PureLeaf x) >>= f = f x\r\n-- However, wouldn't you get stuck on these?\r\n-- (LiftLeaf x g) >>= f = ?monads_yikes_2\r\n-- (Branch x y g) >>= f = ?monads_yikes_3\r\n-- It seems that we have insufficient power to smash down the results, since we\r\n-- cannot actually produce the tree from f in these cases, without introducing\r\n-- another lambda abstraction: but if we do that, we have to wrap it in a tree:\r\n-- but then, inside the lambda abstraction, we cannot destroy the tree that we\r\n-- got out of the f; I take this as a proof that there is no monad instance.\r\n\r\n||| Example specific query GADT\r\ndata FSQry : Type -> Type where\r\n LsFiles : String -> FSQry (List String)\r\n ReadText : String -> FSQry String\r\n DirExists : String -> FSQry Bool\r\n\r\n||| Example accompanying commands, to in conjunction with the FSQry, form a sort\r\n||| of little filesystem DSL.\r\ndata FSCmd\r\n = WriteLines String (List String)\r\n | CreateDir String\r\n | DeleteFile String\r\n | DeleteDir String\r\n\r\nlsFiles : String -> QryTree FSQry (List String)\r\nlsFiles = liftQ . LsFiles\r\n\r\nreadText : String -> QryTree FSQry String\r\nreadText = liftQ . ReadText\r\n\r\nconsolidate' : String -> String -> List String -> List String -> List FSCmd\r\nconsolidate' from to files texts =\r\n map DeleteFile files\r\n ++ [ DeleteDir from\r\n , CreateDir to\r\n , WriteLines (to ++ \"/\" ++ \"consolidated.txt\") texts\r\n ]\r\n\r\n-- Very sadly, it here appears that our type has insufficient power.\r\n--consolidate : String -> String -> QryTree FSQry (List FSCmd)\r\nconsolidate from to = ?tragedy\r\n-- (\\files => consolidate' from to files <$> traverse readText files)\r\n-- <*> lsFiles from\r\n", "meta": {"hexsha": "84128e8e9e9c361b993487e62fb568a12837b5c5", "size": 12193, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "TreeQ.idr", "max_stars_repo_name": "Kazark/queries.idr", "max_stars_repo_head_hexsha": "3c1f0289d2c0bd469db40fe8aba7449282080a65", "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": "TreeQ.idr", "max_issues_repo_name": "Kazark/queries.idr", "max_issues_repo_head_hexsha": "3c1f0289d2c0bd469db40fe8aba7449282080a65", "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": "TreeQ.idr", "max_forks_repo_name": "Kazark/queries.idr", "max_forks_repo_head_hexsha": "3c1f0289d2c0bd469db40fe8aba7449282080a65", "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": 50.5933609959, "max_line_length": 161, "alphanum_fraction": 0.5240711884, "num_tokens": 4118, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085708384736, "lm_q2_score": 0.7025300573952054, "lm_q1q2_score": 0.5517028753440996}}
{"text": "module Main\n\nimport Parity\nimport System\n\ndata Bit : Nat -> Type where\n b0 : Bit 0\n b1 : Bit 1\n\ninstance Show (Bit n) where\n show b0 = \"0\"\n show b1 = \"1\"\n\ninfixl 5 #\n\ndata Binary : (width : Nat) -> (value : Nat) -> Type where\n zero : Binary Z Z\n (#) : %erase v\n Binary w v -> (p : Bit bit) -> Binary (S w) (bit + 2 * v)\n\ninstance Show (Binary w k) where\n show zero = \"\"\n show (bin # bit) = show bin ++ show bit\n\n\n\n\n\n\n\n\npad : Binary w n -> Binary (S w) n\npad zero = zero # b0 \npad (num # x) = pad num # x\n\nnatToBin : (width : Nat) -> (n : Nat) ->\n Maybe (Binary width n)\nnatToBin Z (S k) = Nothing\nnatToBin Z Z = Just zero\nnatToBin (S w) Z = do x <- natToBin w Z\n Just (pad x)\nnatToBin (S w) (S k) with (parity k)\n natToBin (S w) (S (plus j j)) | even = do jbin <- natToBin w j\n let value = jbin # b1\n ?ntbEven\n natToBin (S w) (S (S (plus j j))) | odd = do jbin <- natToBin w (S j)\n let value = jbin # b0\n ?ntbOdd\n\n\n\n\n\n\n\n\n\n\n\npattern syntax bitpair [x] [y] = (_ ** (_ ** (x, y, _)))\nterm syntax bitpair [x] [y] = (_ ** (_ ** (x, y, refl)))\n\naddBit : Bit x -> Bit y -> Bit c -> \n (bx ** (by ** (Bit bx, Bit by, c + x + y = by + 2 * bx)))\naddBit b0 b0 b0 = bitpair b0 b0\naddBit b0 b0 b1 = bitpair b0 b1 \naddBit b0 b1 b0 = bitpair b0 b1\naddBit b0 b1 b1 = bitpair b1 b0\naddBit b1 b0 b0 = bitpair b0 b1 \naddBit b1 b0 b1 = bitpair b1 b0 \naddBit b1 b1 b0 = bitpair b1 b0 \naddBit b1 b1 b1 = bitpair b1 b1 \n\nadc : Binary w x -> Binary w y -> Bit c -> Binary (S w) (c + x + y) \nadc zero zero carry ?= zero # carry\nadc (numx # bx) (numy # by) carry\n ?= let (bitpair carry0 lsb) = addBit bx by carry in \n adc numx numy carry0 # lsb\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n------------\n\nreadNum : IO Nat\nreadNum = do putStr \"Enter a number:\"\n return (fromInteger (cast !getLine))\n\nmainLoop : Int -> IO ()\nmainLoop i\n = do putStrLn $ \"Calc \" ++ show i\n let Just bin1 = natToBin 8 !readNum\n print bin1\n let Just bin2 = natToBin 8 !readNum\n print bin2\n print (adc bin1 bin2 b0)\n mainLoop (i + 1)\n\nmain : IO ()\nmain = mainLoop 1\n\n\n\n\n\n \n---------- Proofs ----------\n\nMain.ntbOdd = proof {\n intro w,j;\n rewrite sym (plusZeroRightNeutral j);\n rewrite plusSuccRightSucc j j;\n intros;\n refine Just;\n trivial;\n}\n\nMain.ntbEven = proof {\n compute;\n intro w,j;\n rewrite sym (plusZeroRightNeutral j);\n intros;\n refine Just;\n trivial;\n}\n\n-- There is almost certainly an easier proof. I don't care, for now :)\n\nMain.adc_lemma_2 = proof {\n intro c,w,v,bit0,num0;\n intro b0,v1,bit1,num1,b1;\n intro bc,x,x1,bx,bx1;\n rewrite sym (plusZeroRightNeutral x);\n rewrite sym (plusZeroRightNeutral v1);\n rewrite sym (plusZeroRightNeutral (plus (plus x v) v1));\n rewrite sym (plusZeroRightNeutral v);\n intros;\n rewrite sym (plusAssociative (plus c (plus bit0 (plus v v))) bit1 (plus v1 v1));\n rewrite (plusAssociative c (plus bit0 (plus v v)) bit1);\n rewrite (plusAssociative bit0 (plus v v) bit1);\n rewrite plusCommutative bit1 (plus v v);\n rewrite sym (plusAssociative c bit0 (plus bit1 (plus v v)));\n rewrite sym (plusAssociative (plus c bit0) bit1 (plus v v));\n rewrite sym b;\n rewrite plusAssociative x1 (plus x x) (plus v v);\n rewrite plusAssociative x x (plus v v);\n rewrite sym (plusAssociative x v v);\n rewrite plusCommutative v (plus x v);\n rewrite sym (plusAssociative x v (plus x v));\n rewrite (plusAssociative x1 (plus (plus x v) (plus x v)) (plus v1 v1));\n rewrite sym (plusAssociative (plus (plus x v) (plus x v)) v1 v1);\n rewrite (plusAssociative (plus x v) (plus x v) v1);\n rewrite (plusCommutative v1 (plus x v));\n rewrite sym (plusAssociative (plus x v) v1 (plus x v));\n rewrite (plusAssociative (plus (plus x v) v1) (plus x v) v1);\n trivial;\n}\n\nMain.adc_lemma_1 = proof {\n intros;\n rewrite sym (plusZeroRightNeutral c) ;\n trivial;\n}\n\n", "meta": {"hexsha": "a8fcaa84f1b9a56761d8202cb7833d3bfd8baf36", "size": 4182, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Binary/binary-final.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": "Binary/binary-final.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": "Binary/binary-final.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": 23.3631284916, "max_line_length": 84, "alphanum_fraction": 0.5645624103, "num_tokens": 1334, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8289387998695209, "lm_q2_score": 0.665410558746814, "lm_q1q2_score": 0.5515846299880913}}
{"text": "module Flexidisc.OrdList.Diff\n\nimport public Flexidisc.OrdList.Disjoint\nimport public Flexidisc.OrdList.Fresh\nimport public Flexidisc.OrdList.Label\nimport public Flexidisc.OrdList.Sub\nimport public Flexidisc.OrdList.Type\n\n%default total\n%access public export\n\n||| compute the difference between the first and the second list.\ndiffKeys : DecEq k => (xs, ys : OrdList k v o) -> OrdList k v o\ndiffKeys [] ys = []\ndiffKeys ((lx, vx) :: xs) ys with (decFresh lx ys)\n | Yes prf = (lx, vx) :: diffKeys xs ys\n | No contra = diffKeys xs ys\n\n||| Apply a patch `xs` to an `OrdList` `ys`.\n||| The label of `ys` that are in `xs` are updated,\n||| and the fresh element of `xs` are added\npatch : DecEq k => (xs, ys : OrdList k v o) -> OrdList k v o\npatch xs ys = merge (diffKeys ys xs) xs\n\ndiffIsSub : DecEq k => {xs : OrdList k v o} -> Sub (diffKeys xs ys) xs\ndiffIsSub {xs = []} = Empty\ndiffIsSub {xs = (lx, vx) :: xs} {ys} with (decFresh lx ys)\n | Yes prf = Keep diffIsSub\n | No contra = Skip diffIsSub\n\ndiffIsDisjoint : DecEq k => {xs : OrdList k v o} ->\n Disjoint (diffKeys xs ys) ys\ndiffIsDisjoint {xs = []} = []\ndiffIsDisjoint {xs = (kx, vx) :: xs} {ys} with (decFresh kx ys)\n | Yes prf = isFreshFromEvidence prf :: diffIsDisjoint\n | No contra = diffIsDisjoint\n", "meta": {"hexsha": "cdcae26d8f610ae30c2bad86758617318dc800a0", "size": 1280, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Flexidisc/OrdList/Diff.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/Diff.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/Diff.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.5945945946, "max_line_length": 70, "alphanum_fraction": 0.66796875, "num_tokens": 425, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8080672227971211, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.5515654567029952}}
{"text": "import Data.List\nimport Data.List1\nimport Data.String.Parser\n\nimport System.File\n\nCoord : Type\nCoord = (Nat, Nat)\n\nDots : Type\nDots = List Coord\n\ndata Fold = Up Nat | Left Nat\n\nShow Fold where\n show (Up n) = \"fold up \" ++ show n\n show (Left n) = \"fold left \" ++ show n\n\nInput : Type\nInput = (Dots, List Fold)\n\npairParser : Parser Coord\npairParser = do x <- natural\n token \",\"\n y <- natural\n pure (x, y)\n\nfoldParser : Parser Fold\nfoldParser = do token \"fold along\"\n (token \"y=\" *> Up <$> natural) <|>\n (token \"x=\" *> Left <$> natural)\n\nparser : Parser Input\nparser = do coords <- some (pairParser <* spaces)\n spaces\n folds <- some (foldParser <* spaces)\n pure (coords, folds)\n\n\nfold1 : Fold -> Coord -> Coord\nfold1 (Up f) (x, y) = if y > f\n then (x, minus f (minus y f))\n else (x, y)\nfold1 (Left f) (x, y) = if x > f\n then (minus f (minus x f), y)\n else (x, y)\n\nfold : Fold -> Dots -> Dots\nfold f dots = .head <$> (group $ sort $ fold1 f <$> dots)\n\npart1 : Input -> IO String\npart1 (dots, []) = pure \"No folds\"\npart1 (dots, (f :: _)) = pure $ show $ length $ fold f dots\n\n\nprintDots : Coord -> Dots -> IO ()\nprintDots (_, _) [] = pure ()\nprintDots (lx, ly) ((y, x) :: cs) = \n do if y > ly\n then putStr $ pack $ replicate (minus y ly) '\\n'\n else putStr $ pack $ replicate (minus x (lx + 1)) ' '\n putChar '#'\n printDots (x, y) cs\n\npart2 : Input -> IO String\npart2 (dots, fs) = do let r = sort $ (\\(x, y) => (y, x)) <$> foldl (flip fold) dots fs\n printDots (0, 0) r\n pure \"\"\n\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": "746cd67d7a252996ffe9ccd45eae623065241296", "size": 2004, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "13/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": "13/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": "13/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": 25.3670886076, "max_line_length": 86, "alphanum_fraction": 0.50249501, "num_tokens": 568, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.837619947119304, "lm_q2_score": 0.658417500561683, "lm_q1q2_score": 0.5515036320029012}}
{"text": "module Simplicity\n\n-- Simplicity, based on https://blockstream.com/simplicity.pdf\n\ndata Ty = One | Sum Ty Ty | Prod Ty Ty\n\ninterpTy : Ty -> Type\ninterpTy One = Unit\ninterpTy (Sum x y) = Either (interpTy x) (interpTy y)\ninterpTy (Prod x y) = ((interpTy x), (interpTy y))\n\ndata Term : Ty -> Ty -> Type where\n Iden : Term a a\n Comp : Term a b -> Term b c -> Term a c\n Unit : Term a One\n InjL : Term a b -> Term a (Sum b c)\n InjR : Term a c -> Term a (Sum b c)\n Case : Term (Prod a c) d -> Term (Prod b c) d -> Term (Prod (Sum a b) c) d\n Pair : Term a b -> Term a c -> Term a (Prod b c)\n Take : Term a c -> Term (Prod a b) c\n Drop : Term b c -> Term (Prod a b) c\n\neval : Term a b -> interpTy a -> interpTy b\neval Iden = \\a => a\neval (Comp x y) = \\a => eval y (eval x a)\neval Unit = \\_ => ()\neval (InjL x) = \\a => Left (eval x a)\neval (InjR x) = \\a => Right (eval x a)\neval (Case x y) = \\(ab, c) => case ab of\n Left l => eval x (l, c)\n Right r => eval y (r, c)\neval (Pair x y) = \\a => ((eval x a), (eval y a))\neval (Take x) = \\(a, b) => eval x a\neval (Drop x) = \\(a, b) => eval x b\n\nBit : Ty\nBit = Sum One One\n\nnot : Term Bit Bit\nnot = Comp (Pair Iden Unit) (Case (InjR Unit) (InjL Unit))\n\nnot' : interpTy Bit -> interpTy Bit\nnot' b = eval not b\n\nzero : interpTy Bit\nzero = Left ()\n\none : interpTy Bit\none = Right ()\n\ntest : interpTy Bit\ntest = not' zero\n", "meta": {"hexsha": "3207980000ac71aae80e3c7626e59f04bfea2d2a", "size": 1421, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Simplicity.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/Simplicity.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/Simplicity.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.8113207547, "max_line_length": 76, "alphanum_fraction": 0.5573539761, "num_tokens": 498, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511396138365, "lm_q2_score": 0.6442250996557036, "lm_q1q2_score": 0.5513607857081714}}
{"text": "import Data.Vect\n\n-- validConv : (Num t) => Vect (m + n) t -> Vect m t -> Vect (n + 1) t\n-- validConv xs w = fromList [sum (window i (length w) xs) | i <- [0..length(xs)-length(w)]]\n\nwindow : (i : Nat) -> (m : Nat) -> Vect (i + (m + n)) t -> Vect m t\nwindow i m xs = take m (drop i xs)\n\n-- xs : Vect 5 Int\n-- xs = [1,2,3,4,5]\n\n-- ys : List (Vect 3 Int)\n-- ys = [window i 3 xs | i <- [1,3]]\n", "meta": {"hexsha": "e032f5cafc0ae536c011198e3a3540d60780d7e3", "size": 390, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "2021/day-01/solve.idr", "max_stars_repo_name": "alexandru-dinu/aoc-2020", "max_stars_repo_head_hexsha": "c7a5f648ea6fceb90ee3e2c1b9dd24bf206cf15f", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2021-12-03T11:56:56.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-03T11:56:56.000Z", "max_issues_repo_path": "2021/day-01/solve.idr", "max_issues_repo_name": "alexandru-dinu/aoc-2020", "max_issues_repo_head_hexsha": "c7a5f648ea6fceb90ee3e2c1b9dd24bf206cf15f", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 9, "max_issues_repo_issues_event_min_datetime": "2021-12-04T19:16:06.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-21T16:43:05.000Z", "max_forks_repo_path": "2021/day-01/solve.idr", "max_forks_repo_name": "alexandru-dinu/aoc-2020", "max_forks_repo_head_hexsha": "c7a5f648ea6fceb90ee3e2c1b9dd24bf206cf15f", "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": 27.8571428571, "max_line_length": 92, "alphanum_fraction": 0.5102564103, "num_tokens": 157, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7772998611746912, "lm_q2_score": 0.7090191399336402, "lm_q1q2_score": 0.5511204790406175}}
{"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 definitions of function optimizers.\nmodule Optimize\n\nimport Tensor\n\n||| An `Optimizer` finds the value, in a `Tensor`-valued feature space, which (approximately)\n||| optimizes a scalar-valued function over that space.\n|||\n||| If the function is not well-defined at points in the feature space, and this is expressed by\n||| wrapping function values in some context, this extra context can be captured in the value `m`.\n||| For example, a function `a -> Maybe (Tensor [] Double)`, can be optimized by an\n||| `Optimizer {m=Maybe} a`.\n|||\n||| @domain The type of the domain over which to find the optimizer.\npublic export 0\nOptimizer : {default id 0 m : Type -> Type} -> (0 domain : Type) -> Type\nOptimizer a = (a -> m $ Tensor [] Double) -> m a\n\n||| Construct an `Optimizer` that implements grid search over a scalar feature space. Grid search\n||| approximates the optimum by evaluating the objective over a finite, evenly-spaced grid.\n|||\n||| @density The density of the grid.\n||| @lower The lower (inclusive) bound of the grid.\n||| @upper The upper (exclusive) bound of the grid.\nexport\ngridSearch : (density : Tensor [d] Int) ->\n (lower : Tensor [d] Double) ->\n (upper : Tensor [d] Double) ->\n Optimizer (Tensor [d] Double)\n\n||| The limited-memory BFGS (L-BFGS) optimization tactic, see\n|||\n||| Nocedal, Jorge, Updating quasi-Newton matrices with limited storage.\n||| Math. Comp. 35 (1980), no. 151, 773–782.\n|||\n||| available at\n|||\n||| https://www.ams.org/journals/mcom/1980-35-151/S0025-5718-1980-0572855-7/\n|||\n||| @initial_points The points from which to start optimization.\nexport\nlbfgs : (initial_points : Tensor [n] Double) -> Optimizer (Tensor [n] Double)\n", "meta": {"hexsha": "fbf84bac4387266ebd31a914a81677d04808e56f", "size": 2288, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Optimize.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/Optimize.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/Optimize.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.4482758621, "max_line_length": 98, "alphanum_fraction": 0.7106643357, "num_tokens": 588, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8459424373085145, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.5510087217683595}}
{"text": "module InsertionSort\nimport Data.Vect\n\nimport Sorted\nimport Card\nimport ElemsAreSame\n\n\nrestLemma : (s : GTE (cardValue y) (cardValue z)) -> (r_prf : GTE (cardValue y) (cardValue x)) -> (restIsSorted : Sorted rest) -> (restHead : HeadIsEither rest x z) -> (w : Sorted (z :: ys)) -> Sorted (y :: rest)\nrestLemma {y} s r_prf restIsSorted HeadIsLeft w = SortMany y restIsSorted r_prf\nrestLemma {y} s r_prf restIsSorted HeadIsRight w = SortMany y restIsSorted s\n\nelemsSwap : (restElems : ElemsAreSame (x :: (z :: ys)) rest) -> ElemsAreSame (x :: (y :: (z :: ys))) (y :: rest)\nelemsSwap {y} restElems = swapHeads (PrependXIsPrependX y restElems)\n\n\ntotal insert': (x: Card) -> (ys: Vect (S n) Card) -> Sorted ys -> HeadIs ys y -> (z:Vect (S (S n)) Card **(Sorted z, ElemsAreSame (x::ys) z, HeadIsEither z x y))\ninsert' x (y::[]) SortSingle MkHeadIs = case chooseGte (cardValue x) (cardValue y) of\n (Left l_prf) => (x::y::[] **(SortMany x SortSingle l_prf, PrependXIsPrependX x (PrependXIsPrependX y NilIsNil), HeadIsLeft))\n (Right r_prf) => (y::x::[] **(SortMany y SortSingle r_prf, PrependXYIsPrependYX x y NilIsNil, HeadIsRight))\ninsert' x (y::(z :: ys)) (SortMany y w s) MkHeadIs = case chooseGte (cardValue x) (cardValue y) of\n (Left l_prf) => (x::y::z::ys ** (SortMany x (SortMany y w s) l_prf,\n PrependXIsPrependX x (PrependXIsPrependX y (PrependXIsPrependX z (sameListsAreSame ys))),\n HeadIsLeft))\n (Right r_prf) => let (rest ** (restIsSorted, restElems, restHead)) = insert' x (z::ys) (tailIsSortedToo (SortMany y w s)) MkHeadIs in\n (y::rest ** (restLemma s r_prf restIsSorted restHead w,\n elemsSwap restElems,\n HeadIsRight))\n\ninsert : (x: Card) -> (xs:Vect n Card) -> Sorted xs -> (z:Vect (S n) Card ** (Sorted z, ElemsAreSame (x::xs) z))\ninsert x [] sort_pf = ([x] ** (SortSingle, PrependXIsPrependX x NilIsNil))\ninsert x (y::ys) sort_pf = let (sortedList ** (sort_prf, sort_elems_prf, head_prf)) = insert' x (y::ys) sort_pf MkHeadIs in\n (sortedList ** (sort_prf, sort_elems_prf))\n\n\n\nexport insertSort: (x:Vect n Card) -> (y:Vect n Card ** (Sorted y, ElemsAreSame x y))\ninsertSort [] = ([] ** (SortEmpty, NilIsNil))\ninsertSort (x :: []) = ([x] ** (SortSingle,(PrependXIsPrependX x NilIsNil)))\ninsertSort (x :: xs) = let (rest ** (sort, elem)) = insertSort xs\n (y ** (o_sort, o_elems)) = insert x rest sort\n elem_prf_new = PrependXIsPrependX x elem\n o_elems_new = SamenessIsTransitive elem_prf_new o_elems\n in\n (y ** (o_sort, o_elems_new))\n", "meta": {"hexsha": "afbc1946486e55d90f24b1a0d6af113f5be2c7fc", "size": 3183, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Poker/InsertionSort.idr", "max_stars_repo_name": "as8709/PokerHands", "max_stars_repo_head_hexsha": "873a9b646ff5f021b4af80ac3325d51397639716", "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": "Poker/InsertionSort.idr", "max_issues_repo_name": "as8709/PokerHands", "max_issues_repo_head_hexsha": "873a9b646ff5f021b4af80ac3325d51397639716", "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": "Poker/InsertionSort.idr", "max_forks_repo_name": "as8709/PokerHands", "max_forks_repo_head_hexsha": "873a9b646ff5f021b4af80ac3325d51397639716", "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": 69.1956521739, "max_line_length": 212, "alphanum_fraction": 0.5224630851, "num_tokens": 881, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707283, "lm_q2_score": 0.7154240018510026, "lm_q1q2_score": 0.5502184609496582}}
{"text": "module Data.SnocVect\n\nimport Data.Vect\n\n%hide Prelude.Types.elem\n\n%default total\n\n||| A Backwards Vect\npublic export\ndata SnocVect : Nat -> Type -> Type where\n ||| Empty snoc-vect\n Lin : SnocVect 0 a\n\n ||| A non-empty snoc-vect, consisting of the rest of the snoc-vect and the final element.\n (:<) : (SnocVect n a) -> a -> SnocVect (S n) a\n\n%name SnocVect sx, sy, sz\n\ninfixl 7 <><\ninfixr 6 <>>\n\n||| 'fish': Action of lists on snoc-lists\npublic export\n(<><) : SnocVect n a -> Vect m a -> SnocVect (n + m) a\nsx <>< [] = rewrite plusZeroRightNeutral n in sx\nsx <>< ((::) x xs {len}) =\n rewrite sym $ plusSuccRightSucc n len in\n sx :< x <>< xs\n\n||| 'chips': Action of snoc-lists on lists\npublic export\n(<>>) : SnocVect j a -> Vect k a -> Vect (j + k) a\nLin <>> xs = xs\n((:<) sx x {n}) <>> xs =\n rewrite plusSuccRightSucc n k in\n sx <>> x :: xs\n\nexport\nCast (SnocVect n a) (Vect n a) where\n cast sx = rewrite sym $ plusZeroRightNeutral n in\n sx <>> []\n\nexport\nCast (Vect n a) (SnocVect n a) where\n cast xs = Lin <>< xs\n\n||| Transform to a vect but keeping the contents in the spine order (term depth).\npublic export\nasVect : SnocVect n type -> Vect n type\nasVect = (reverse . cast)\n\npublic export\nEq a => Eq (SnocVect n a) where\n (==) Lin Lin = True\n (==) (sx :< x) (sy :< y) = x == y && sx == sy\n (==) _ _ = False\n\npublic export\nOrd a => Ord (SnocVect n a) where\n compare Lin Lin = EQ\n compare (sx :< x) (sy :< y)\n = case compare sx sy of\n EQ => compare x y\n c => c\n\n||| True iff input is Lin\npublic export\nisLin : SnocVect n a -> Bool\nisLin Lin = True\nisLin (sx :< x) = False\n\n||| True iff input is (:<)\npublic export\nisSnoc : SnocVect n a -> Bool\nisSnoc Lin = False\nisSnoc (sx :< x) = True\n\npublic export\n(++) : (sx : SnocVect j a) -> (sy : SnocVect k a) -> SnocVect (j + k) a\n(++) sx Lin = rewrite plusZeroRightNeutral j in sx\n(++) sx ((:<) sy y {n}) =\n rewrite sym $ plusSuccRightSucc j n in\n (sx ++ sy) :< y\n\npublic export\nlength : SnocVect n a -> Nat\nlength Lin = Z\nlength (sx :< x) = S $ length sx\n\nexport\nlengthCorrect : (sx : SnocVect n a) -> length sx = n\nlengthCorrect [<] = Refl\nlengthCorrect (sx :< x) = cong S (lengthCorrect sx)\n\npublic export\nreplicate : (k : Nat) -> a -> SnocVect k a\nreplicate 0 x = [<]\nreplicate (S k) x = replicate k x :< x\n\n||| The \"head\" of the snoc-vect\npublic export\ndeah : SnocVect (S n) a -> a\ndeah (sx :< x) = x\n\n||| The \"tail\" of the snoc-vect\npublic export\nliat : SnocVect (S n) a -> SnocVect n a\nliat (sx :< x) = sx\n\nexport\nShow a => Show (SnocVect n a) where\n show sx = concat (\"[< \" :: intersperse \", \" (show' [] sx) ++ [\"]\"])\n where\n show' : Vect j String -> SnocVect k a -> Vect (j + k) String\n show' acc Lin = rewrite plusZeroRightNeutral j in acc\n show' acc ((:<) xs x {n}) = \n rewrite sym $ plusSuccRightSucc j n in\n show' (show x :: acc) xs\n\npublic export\nFunctor (SnocVect n) where\n map f Lin = Lin\n map f (sx :< x) = (map f sx) :< (f x)\n\npublic export\nZippable (SnocVect k) where\n zipWith _ [<] [<] = [<]\n zipWith f (sx :< x) (sy :< y) = zipWith f sx sy :< f x y\n\n zipWith3 _ [<] [<] [<] = [<]\n zipWith3 f (sx :< x) (sy :< y) (sz :< z) = zipWith3 f sx sy sz :< f x y z \n\n unzipWith f [<] = ([<], [<])\n unzipWith f (sx :< x) = let (b, c) = f x\n (sb, sc) = unzipWith f sx in\n (sb :< b, sc :< c)\n\n unzipWith3 f [<] = ([<], [<], [<])\n unzipWith3 f (sx :< x) = let (b, c, d) = f x\n (sb, sc, sd) = unzipWith3 f sx in\n (sb :< b, sc :< c, sd :< d)\n\npublic export\nSemigroup a => Semigroup (SnocVect n a) where\n (<+>) = zipWith (<+>)\n\npublic export\n{k : Nat} -> Monoid a => Monoid (SnocVect k a) where\n neutral = replicate k neutral\n\npublic export\nFoldable (SnocVect n) where\n foldr f z = foldr f z . (<>> [])\n\n foldl f z xs = h xs where\n h : SnocVect k elem -> acc\n h Lin = z\n h (xs :< x) = f (h xs) x\n\n null Lin = True\n null (_ :< _) = False\n\n toList = toList . (<>> [])\n\n foldMap f = foldl (\\xs, x => xs <+> f x) neutral\n\npublic export\n{k : Nat} -> Applicative (SnocVect k) where\n pure = replicate _\n fs <*> sx = zipWith apply fs sx\n\n||| Get diagonal elements\npublic export\ndiag : SnocVect len (SnocVect len elem) -> SnocVect len elem\ndiag [<] = [<]\ndiag (ssx :< (sx :< x)) = diag (map liat ssx) :< x\n\n||| This monad is different from the List monad, (>>=)\n||| uses the diagonal.\npublic export\n{k : Nat} -> Monad (SnocVect k) where\n sx >>= f = diag (map f sx)\n\npublic export\nTraversable (SnocVect k) where\n traverse _ Lin = pure Lin\n traverse f (xs :< x) = [| traverse f xs :< f x |]\n\n||| Check if something is a member of a snoc-vect using the default Boolean equality.\npublic export\nelem : Eq a => a -> SnocVect k a -> Bool\nelem x Lin = False\nelem x (sx :< y) = x == y || elem x sx\n\n||| Find the first element of the snoc-vect that satisfies the predicate.\npublic export\nfind : (a -> Bool) -> SnocVect k a -> Maybe a\nfind p Lin = Nothing\nfind p (xs :< x) = if p x then Just x else find p xs\n\n||| Satisfiable if `k` is a valid index into `xs`.\n|||\n||| @ k the potential index\n||| @ xs the snoc-list into which k may be an index\npublic export\ndata InBounds : (k : Nat) -> (xs : SnocVect j a) -> Type where\n ||| Z is a valid index into any cons cell\n InFirst : InBounds Z (xs :< x)\n ||| Valid indices can be extended\n InLater : InBounds k xs -> InBounds (S k) (xs :< x)\n\n||| Find the index and proof of InBounds of the first element (if exists) of a\n||| snoc-list that satisfies the given test, else `Nothing`.\npublic export\nfindIndex : (a -> Bool) -> (sx : SnocVect k a) -> Maybe $ Fin (length sx)\nfindIndex _ Lin = Nothing\nfindIndex p (xs :< x) = if p x\n then Just FZ\n else FS <$> findIndex p xs\n", "meta": {"hexsha": "edf9aaeb28b90441d04c3db108aa53d4fe0661ba", "size": 5866, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "src/Data/SnocVect.idr", "max_stars_repo_name": "mattpolzin/idris-snocvect", "max_stars_repo_head_hexsha": "f6148c3d06c7a9989062a2425f925fc844468215", "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/Data/SnocVect.idr", "max_issues_repo_name": "mattpolzin/idris-snocvect", "max_issues_repo_head_hexsha": "f6148c3d06c7a9989062a2425f925fc844468215", "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/SnocVect.idr", "max_forks_repo_name": "mattpolzin/idris-snocvect", "max_forks_repo_head_hexsha": "f6148c3d06c7a9989062a2425f925fc844468215", "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": 26.5429864253, "max_line_length": 91, "alphanum_fraction": 0.5770542107, "num_tokens": 2012, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851918, "lm_q2_score": 0.7154239957834733, "lm_q1q2_score": 0.5502184487100945}}
{"text": "module Hoare2\n\nimport Assn\nimport Expr\nimport Hoare\nimport Imp\nimport Logic\nimport Maps\n\n%access public export\n\n%default total\n\nreduce_to_zero : Com\nreduce_to_zero = WHILE (not (X == 0)) $\n X ::= X - 1\n\nreduce_to_zero_correct : HoareTriple (const ())\n Hoare2.reduce_to_zero\n (\\st => st X = 0)\nreduce_to_zero_correct =\n let htc = hoare_consequence_pre\n (\\st => ((), BAssn (not (X == 0)) st))\n (AssignSub X (X - 1) (const ()))\n (const ())\n (hoare_assign (const ()))\n (\\_, _ => ())\n htw = hoare_while (const ()) htc\n in hoare_consequence_post\n (const ())\n (\\st => st X = 0)\n (\\st => ((), Not (BAssn (not (X == 0)) st)))\n htw\n (\\st, (_, contra) =>\n fst (nat_beq_iff (st X) 0)\n (trans (sym (notInvolutive (st X == 0)))\n (cong {f=not} (fst not_true_iff_false contra))))\n\nslow_assignment : Com\nslow_assignment = do\n {-\n {{ X = m }}\n ->> {{ (X = m, Y = n) }}\n -}\n Y ::= 0\n {-\n {{ (X = m, Y = 0) }}\n ->> {{ X + Y = m }}\n -}\n WHILE (not (X == 0)) $ do\n {-\n {{ (X + Y = m, not (X == 0)) }}\n ->> {{ X - 1 + Y + 1 = m }}\n -}\n X ::= X - 1\n -- {{ X + Y + 1 = m }}\n Y ::= Y + 1\n -- {{ X + Y = m }}\n {-\n {{ (X + Y = m, Not (not (X == 0))) }}\n ->> {{ Y = m }}\n -}\n\nslow_assignment_correct : HoareTriple (\\st => st X = m)\n Hoare2.slow_assignment\n (\\st => st Y = m)\nslow_assignment_correct {m} =\n let hty = hoare_consequence_pre\n (\\st => st X = m)\n (AssignSub Y 0 (\\st => (st X = m, st Y = 0)))\n (\\st => (st X = m, st Y = 0))\n (hoare_assign (\\st => (st X = m, st Y = 0)))\n (\\st, p_st => (p_st, Refl))\n htx = hoare_consequence_pre\n (\\st => (st X + st Y = m, BAssn (not (X == 0)) st))\n (\\st => minus (st X) 1 + (st Y + 1) = m)\n (\\st => st X + (st Y + 1) = m)\n (hoare_assign (\\st => st X + (st Y + 1) = m))\n (\\st, (prf, x_prf) =>\n let lte_prf =\n notZeroImpliesGTZero\n (fst (nat_nbeq_iff (st X) 0)\n (trans (sym (notInvolutive (st X == 0)))\n (cong {f=not} x_prf)))\n in rewrite sym prf\n in lte_minus_plus_sum lte_prf)\n hty' = hoare_assign (\\st => st X + st Y = m)\n ht_body = hoare_seq (\\st => (st X + st Y = m, BAssn (not (X == 0)) st))\n (\\st => st X + (st Y + 1) = m)\n (\\st => st X + st Y = m)\n hty'\n htx\n htw = hoare_consequence_pre\n (\\st => (st X = m, st Y = 0))\n (\\st => st X + st Y = m)\n (\\st => (st X + st Y = m, Not (BAssn (not (X == 0)) st)))\n (hoare_while (\\st => st X + st Y = m) ht_body)\n (\\_, (x_prf, y_prf) => trans (plusCong x_prf y_prf)\n (plusZeroRightNeutral m))\n ht_program = hoare_seq (\\st => st X = m)\n (\\st => (st X = m, st Y = 0))\n (\\st => ( st X + st Y = m\n , Not (BAssn (not (X == 0)) st) ))\n htw\n hty\n in hoare_consequence_post\n (\\st => st X = m)\n (\\st => st Y = m)\n (\\st => (st X + st Y = m, Not (BAssn (not (X == 0)) st)))\n ht_program\n (\\st, (prf, contra) =>\n let st_X_eq_0 =\n fst (nat_beq_iff (st X) 0)\n (trans (sym (notInvolutive (st X == 0)))\n (cong {f=not} (fst not_true_iff_false contra)))\n in replace {P=\\x => x + st Y = m} st_X_eq_0 prf)\n\nadd_slowly : Com\nadd_slowly =\n {-\n {{ (X = m, Z = n) }}\n ->> {{ X + Z = m + n }}\n -}\n WHILE (not (X == 0)) $ do\n {-\n {{ (X + Z = m + n, BAssn (not (X == 0)) st) }}\n ->> {{ X - 1 + Z + 1 = m + n }}\n -}\n Z ::= Z + 1\n -- {{ X - 1 + Z = m + n }}\n X ::= X - 1\n -- {{ X + Z = m + n }}\n {-\n {{ (X + Z = m + n, Not (BAssn (not (X == 0)) st)) }}\n ->> {{ Z = m + n }}\n -}\n\nparity : Nat -> Nat\nparity Z = 0\nparity (S Z) = 1\nparity (S (S k)) = parity k\n\nparity_ge_2 : (n : Nat) -> LTE 2 n -> parity (minus n 2) = parity n\nparity_ge_2 Z lte_prf = absurd $ succNotLTEzero lte_prf\nparity_ge_2 (S Z) lte_prf = absurd $ succNotLTEzero (fromLteSucc lte_prf)\nparity_ge_2 (S (S k)) lte_prf = rewrite minusZeroRight k\n in Refl\n\nparity_lt_2 : (n : Nat) -> Not (LTE 2 n) -> parity n = n\nparity_lt_2 Z _ = Refl\nparity_lt_2 (S Z) _ = Refl\nparity_lt_2 (S (S k)) contra =\n let lte_prf = notLTImpliesGTE contra\n in absurd $ succNotLTEzero (fromLteSucc lte_prf)\n\nparity_correct : HoareTriple (\\st => st X = m)\n (WHILE (2 <= X) $ do\n X ::= X - 2)\n (\\st => st X = parity m)\nparity_correct {m} =\n let htx = hoare_consequence_pre\n (\\st => (parity (st X) = parity m, BAssn (2 <= X) st))\n (AssignSub X (X - 2) (\\st => parity (st X) = parity m))\n (\\st => parity (st X) = parity m)\n (hoare_assign (\\st => parity (st X) = parity m))\n (\\st, (prf, cond_prf) =>\n rewrite parity_ge_2 (st X)\n (fst (lte_beq_iff 2 (st X)) cond_prf)\n in prf)\n htw = hoare_while (\\st => parity (st X) = parity m) htx\n in hoare_consequence\n (\\st => st X = m)\n (\\st => parity (st X) = parity m)\n (\\st => st X = parity m)\n (\\st => (parity (st X) = parity m, Not (BAssn (2 <= X) st)))\n htw\n (\\st, p_st => cong p_st)\n (\\st, (prf, nbeq_prf) =>\n let lte_prf = fst (lte_nbeq_iff 2 (st X))\n (fst not_true_iff_false nbeq_prf)\n contra = fromNotLteSucc (lteImpliesNotGT lte_prf)\n in rewrite sym prf\n in sym (parity_lt_2 (st X) contra))\n\nfactorial : Com\nfactorial = do\n {-\n {{ X = m }}\n ->> {{ 1 * X! = m! }}\n -}\n Y ::= 1\n -- {{ Y * X! = m! }}\n WHILE (not (X == 0)) $ do\n {-\n {{ (Y * X! = m!, BAssn (not (X == 0)) st) }}\n ->> {{ Y * X * (X - 1)! = m! }}\n -}\n Y ::= Y * X\n -- {{ Y * (X - 1)! = m! }}\n X ::= X - 1\n -- {{ Y * X! = m! }}\n {-\n {{ (Y * X! = m!, Not (BAssn (not (X == 0)) st)) }}\n ->> {{ Y = m! }}\n -}\n\nlemma1 : (x, y : Nat) -> Either (x = 0) (y = 0) -> minimum x y = 0\nlemma1 _ _ (Left x_prf) = rewrite x_prf in Refl\nlemma1 Z _ (Right _) = Refl\nlemma1 (S _) _ (Right y_prf) = rewrite y_prf in Refl\n\nlemma2 : (x, y : Nat) ->\n minimum (x `minus` 1) (y `minus` 1) = minimum x y `minus` 1\nlemma2 Z _ = Refl\nlemma2 (S k) Z = minimumZeroZeroLeft (minus k 0)\nlemma2 (S k) (S j) = rewrite minusZeroRight k\n in rewrite minusZeroRight j\n in rewrite minusZeroRight (minimum k j)\n in Refl\n\nmin : (a, b : Nat) -> Com\nmin a b = do\n {-\n {{ () }}\n ->> {{ 0 = minimum a b - minimum a b }}\n -}\n X ::= ANum a\n -- {{ 0 = minimum a b - minimum X b }}\n Y ::= ANum b\n -- {{ 0 = minimum a b - minimum X Y }}\n Z ::= 0\n -- {{ Z = minimum a b - minimum X Y }}\n WHILE (not (X == 0) && not (Y == 0)) $ do\n {-\n {{ (Z = minimum a b - minimum X Y, BAssn (not (X == 0) && not (Y == 0)) st) }}\n ->> {{ Z + 1 = minimum a b - minimum (X - 1) (Y - 1) }}\n -}\n X ::= X - 1\n -- {{ Z + 1 = minimum a b - minimum X (Y - 1) }}\n Y ::= Y - 1\n -- {{ Z + 1 = minimum a b - minimum X Y }}\n Z ::= Z + 1\n -- {{ Z = minimum a b - minimum X Y }}\n {-\n {{ (Z = minimum a b - minimum X Y, Not (BAssn (not (X == 0) && not (Y == 0)) st)) }}\n ->> {{ Z ::= minimum a b }}\n -}\n\ntwo_loops : (a, b, c : Nat) -> Com\ntwo_loops a b c = do\n {-\n {{ () }}\n ->> {{ c = 0 + 0 + c }}\n -}\n X ::= 0\n -- {{ c = X + 0 + c }}\n Y ::= 0\n -- {{ c = X + Y + c }}\n Z ::= ANum c\n -- {{ Z = X + Y + c }}\n WHILE (not (X == ANum a)) $ do\n {-\n {{ (Z = X + Y + c, BAssn (not (X == a)) st) }}\n ->> {{Z + 1 = X + 1 + Y + c }}\n -}\n X ::= X + 1\n -- {{ Z + 1 = X + Y + c }}\n Z ::= Z + 1\n -- {{ Z = X + Y + c }}\n {-\n {{ (Z = X + Y + c, Not (BAssn (not (X == a)) st)) }}\n ->> {{ Z = a + Y + c }}\n -}\n WHILE (not (Y == ANum b)) $ do\n {-\n {{ (Z = a + Y + c, BAssn (not (Y == b)) st) }}\n ->> {{ Z + 1 = a + Y + 1 + c }}\n -}\n Y ::= Y + 1\n -- {{ Z + 1 = a + Y + c }}\n Z ::= Z + 1\n -- {{ Z = a + Y + c }}\n {-\n {{ (Z = a + Y + c, Not (BAssn (not (Y == b)) st)) }}\n ->> {{ Z = a + b + c }}\n -}\n\ndpow2_down : (m : Nat) -> Com\ndpow2_down m = do\n {-\n {{ () }}\n ->> {{ (1 = 2^(0+1) - 1, 1 = 2^0) }}\n -}\n X ::= 0\n -- {{ (1 = 2^(X+1) - 1, 1 = 2^X) }}\n Y ::= 1\n -- {{ (Y = 2^(X+1) - 1, 1 = 2^X) }}\n Z ::= 1\n -- {{ (Y = 2^(X+1) - 1, Z = 2^X) }}\n WHILE (not (X == ANum m)) $ do\n {-\n {{ (Y = 2^(X+1) - 1, Z = 2^X, BAssn (not (X == m)) st) }}\n ->> {{ (Y + 2*Z = 2^(X+1+1) - 1, 2*Z = 2^(X+1)) }}\n -}\n Z ::= 2 * Z\n -- {{ (Y + Z = 2^(X+1+1) - 1, Z = 2^(X+1)) }}\n Y ::= Y + Z\n -- {{ (Y = 2^(X+1+1) - 1, Z = 2^(X+1)) }}\n X ::= X + 1\n -- {{ (Y = 2^(X+1) - 1, Z = 2^X) }}\n {-\n {{ (Y = 2^(X+1) - 1, Z = 2^X, Not (BAssn (not (X == m)) st)) }}\n ->> {{ Y = 2^(m+1) - 1 }}\n -}\n\nIsWP : (p : Assertion) -> (c : Com) -> (q : Assertion) -> Type\nIsWP p c q = ( HoareTriple p c q\n , (p' : Assertion) -> HoareTriple p' c q -> p' ->> p )\n\n{-\n {{ X = 5 }} SKIP {{ X = 5 }}\n\n {{ Y + Z = 5 }} X ::= Y + Z {{ X = 5 }}\n\n {{ True }} X ::= Y {{ X = Y }}\n\n {{ Either (X = 0, Z = 4) (Not (X = 0), W = 3) }}\n IFB X == 0 THEN Y ::= Z + 1 ELSE Y ::= W + 2 FI\n {{ Y = 5 }}\n\n {{ Void }} X ::= 5 {{ X = 0 }}\n\n {{ () }}\n WHILE BTrue $ do X ::= 0\n {{ X = 0 }}\n-}\n\nis_wp_example : IsWP (\\st => LTE (st Y) 4)\n (X ::= Y + 1)\n (\\st => LTE (st X) 5)\nis_wp_example = (ht, imp)\nwhere ht : HoareTriple (\\st => LTE (st Y) 4) (X ::= Y + 1) (\\st => LTE (st X) 5)\n ht = hoare_consequence_pre (\\st => LTE (st Y) 4)\n (\\st => LTE (st Y + 1) 5)\n (\\st => LTE (st X) 5)\n (hoare_assign (\\st => LTE (st X) 5))\n (\\st, p_st => rewrite plusCommutative (st Y) 1\n in LTESucc p_st)\n imp : (p' : Assertion) ->\n HoareTriple p' (X ::= Y + 1) (\\st => LTE (st X) 5) ->\n p' ->> (\\st => LTE (st Y) 4)\n imp p' ht' st p'_st =\n fromLteSucc (replace {P=\\x => LTE x 5}\n (plusCommutative (st Y) 1)\n (ht' st _ (E_Ass Refl) p'_st))\n\nhoare_assign_weakest : IsWP (AssignSub x a q) (x ::= a) q\nhoare_assign_weakest {x} {a} {q} = (hoare_assign q, imp)\nwhere imp : (p' : Assertion) -> HoareTriple p' (x ::= a) q ->\n p' ->> AssignSub x a q\n imp p' ht st p'_st = ht st _ (E_Ass Refl) p'_st\n", "meta": {"hexsha": "eb4e95e83885b86d6f767de867cb2d65db5fcd55", "size": 11320, "ext": "idr", "lang": "Idris", "max_stars_repo_path": "Hoare2.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": "Hoare2.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": "Hoare2.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": 31.270718232, "max_line_length": 88, "alphanum_fraction": 0.3808303887, "num_tokens": 4105, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7431680086124811, "lm_q2_score": 0.7401743563075446, "lm_q1q2_score": 0.5500739024031029}}