Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
why3
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
82
Issues
82
List
Boards
Labels
Milestones
Merge Requests
10
Merge Requests
10
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Why3
why3
Commits
d2fad71d
Commit
d2fad71d
authored
May 27, 2011
by
Jean-Christophe Filliatre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
factorial example updated and added to the nightly bench
parent
fe8cd6a9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
15 deletions
+58
-15
.gitignore
.gitignore
+3
-0
examples/programs/fact.mlw
examples/programs/fact.mlw
+33
-15
examples/programs/fact/why3session.xml
examples/programs/fact/why3session.xml
+22
-0
No files found.
.gitignore
View file @
d2fad71d
...
...
@@ -34,6 +34,9 @@ why.conf
/bench/programs/good/see/
/bench/programs/good/set/
/bench/programs/good/recfun/
/bench/programs/good/loops/
/bench/programs/good/po/
/bench/valid/list/
# /bin/
/bin/why3.byte
...
...
examples/programs/fact.mlw
View file @
d2fad71d
...
...
@@ -10,23 +10,41 @@ theory Fact "Factorial"
end
module FactRecursive
use import Fact
use import int.Int
let rec fact_rec (x:int) : int variant {x} =
{ x >= 0 }
if x = 0 then 1 else x * fact_rec (x-1)
{ result = fact x }
end
module FactImperative
use import Fact
use import int.Int
use import module ref.Ref
let fact_imp (x:int) : int =
{ x >= 0 }
let y = ref 0 in
let r = ref 1 in
while !y < x do
invariant { 0 <= !y <= x and !r = fact !y }
y := !y + 1;
r := !r * !y
done;
!r
{ result = fact x }
use import Fact
use import int.Int
use import module ref.Ref
let fact_imp (x:int) : int =
{ x >= 0 }
let y = ref 0 in
let r = ref 1 in
while !y < x do
invariant { 0 <= !y <= x and !r = fact !y }
y := !y + 1;
r := !r * !y
done;
!r
{ result = fact x }
end
(*
Local Variables:
compile-command: "unset LANG; make -C ../.. examples/programs/fact.gui"
End:
*)
examples/programs/fact/why3session.xml
0 → 100644
View file @
d2fad71d
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE why3session SYSTEM "why3session.dtd">
<why3session
name=
"examples/programs/fact/why3session.xml"
>
<file
name=
"../fact.mlw"
verified=
"true"
expanded=
"true"
>
<theory
name=
"Fact"
verified=
"true"
expanded=
"true"
>
</theory>
<theory
name=
"FactRecursive"
verified=
"true"
expanded=
"true"
>
<goal
name=
"WP_parameter fact_rec"
expl=
"correctness of parameter fact_rec"
sum=
"26ddbd98b20d38d8cc8174af1ddddb03"
proved=
"true"
expanded=
"true"
>
<proof
prover=
"alt-ergo"
timelimit=
"10"
edited=
""
obsolete=
"false"
>
<result
status=
"valid"
time=
"0.02"
/>
</proof>
</goal>
</theory>
<theory
name=
"FactImperative"
verified=
"true"
expanded=
"true"
>
<goal
name=
"WP_parameter fact_imp"
expl=
"correctness of parameter fact_imp"
sum=
"e351701b7425629858770982d2abae90"
proved=
"true"
expanded=
"true"
>
<proof
prover=
"alt-ergo"
timelimit=
"10"
edited=
""
obsolete=
"false"
>
<result
status=
"valid"
time=
"0.03"
/>
</proof>
</goal>
</theory>
</file>
</why3session>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment