{"id":5584,"date":"2014-08-17T11:13:08","date_gmt":"2014-08-17T11:13:08","guid":{"rendered":"http:\/\/www.lexicalscope.com\/blog\/?p=5584"},"modified":"2014-10-08T15:14:23","modified_gmt":"2014-10-08T15:14:23","slug":"dafny-function-lemmas","status":"publish","type":"post","link":"https:\/\/www.lexicalscope.com\/blog\/2014\/08\/17\/dafny-function-lemmas\/","title":{"rendered":"Dafny Function Lemmas"},"content":{"rendered":"<p>Sometimes it is hard to use a normal Dafny method lemma where you need it. For example, if you want to use a lemma inside a function or in a contract. There is a simple solution.<\/p>\n<p>Given a method lemma:<\/p>\n<pre lang=\"dafny\">\r\nstatic lemma SomethingValid(s:S)\r\n   requires P(s);\r\n   ensures Q(s);\r\n<\/pre>\n<p>We can produce a <a href=\"http:\/\/rise4fun.com\/Dafny\/tutorialcontent\/Lemmas\">function lemma<\/a>:<\/p>\n<pre lang=\"dafny\">\r\nstatic lemma SomethingValidFn(s:S)\r\n   requires P(s);\r\n   ensures Q(s);\r\n   ensures SomethingValidFn(s);\r\n{\r\n   SomethingValid(s); true\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes it is hard to use a normal Dafny method lemma where you need it. For example, if you want to use a lemma inside a function or in a contract. There is a simple solution. Given a method lemma: &hellip; <a href=\"https:\/\/www.lexicalscope.com\/blog\/2014\/08\/17\/dafny-function-lemmas\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[15],"tags":[],"class_list":["post-5584","post","type-post","status-publish","format-standard","hentry","category-dafny"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2e3P7-1s4","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/posts\/5584","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/comments?post=5584"}],"version-history":[{"count":1,"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/posts\/5584\/revisions"}],"predecessor-version":[{"id":5585,"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/posts\/5584\/revisions\/5585"}],"wp:attachment":[{"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/media?parent=5584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/categories?post=5584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lexicalscope.com\/blog\/wp-json\/wp\/v2\/tags?post=5584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}