Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
24688442
Commit
24688442
authored
9 years ago
by
Sandro Stucki
Committed by
Manos Koukoutos
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Adds DSL for proofs.
parent
8120a2a3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
library/proof/Internal.scala
+61
-0
61 additions, 0 deletions
library/proof/Internal.scala
library/proof/package.scala
+59
-0
59 additions, 0 deletions
library/proof/package.scala
with
120 additions
and
0 deletions
library/proof/Internal.scala
0 → 100644
+
61
−
0
View file @
24688442
/* Copyright 2009-2014 EPFL, Lausanne */
package
leon.proof
import
leon.lang._
/** Internal helper classes and methods for the 'proof' package. */
object
Internal
{
/*** Helper classes for relational reasoning ***/
case
class
WithRel
[
A
,
B
](
x
:
A
,
r
:
(
A
,
B
)
=>
Boolean
,
prop
:
Boolean
)
{
/** Continue with the next relation. */
def
^^
(
y
:
B
)
:
RelReasoning
[
B
]
=
{
require
(
prop
==>
r
(
x
,
y
))
RelReasoning
(
y
,
prop
&&
r
(
x
,
y
))
}
/** Add a proof. */
def
^^|
(
proof
:
Boolean
)
:
WithProof
[
A
,
B
]
=
{
require
(
proof
)
WithProof
(
x
,
r
,
proof
,
prop
)
}
/** Short-hand for equational reasoning. */
def
==|
(
proof
:
Boolean
)
:
WithProof
[
A
,
A
]
=
{
require
(
proof
)
WithProof
(
x
,
_
==
_
,
proof
,
prop
)
}
def
qed
:
Boolean
=
prop
}
case
class
WithProof
[
A
,
B
](
x
:
A
,
r
:
(
A
,
B
)
=>
Boolean
,
proof
:
Boolean
,
prop
:
Boolean
)
{
/** Close a proof. */
def
|
[
C
](
that
:
WithProof
[
B
,
C
])
:
WithProof
[
B
,
C
]
=
{
require
(
this
.
prop
&&
this
.
proof
==>
this
.
r
(
this
.
x
,
that
.
x
))
WithProof
(
that
.
x
,
that
.
r
,
that
.
proof
,
this
.
prop
&&
this
.
proof
&&
this
.
r
(
this
.
x
,
that
.
x
))
}
/** Close a proof. */
def
|
[
C
](
that
:
WithRel
[
B
,
C
])
:
WithRel
[
B
,
C
]
=
{
require
(
this
.
prop
&&
this
.
proof
==>
this
.
r
(
this
.
x
,
that
.
x
))
WithRel
(
that
.
x
,
that
.
r
,
this
.
prop
&&
this
.
proof
&&
this
.
r
(
this
.
x
,
that
.
x
))
}
/** Close a proof. */
def
|
(
that
:
RelReasoning
[
B
])
:
RelReasoning
[
B
]
=
{
require
(
this
.
prop
&&
this
.
proof
==>
this
.
r
(
this
.
x
,
that
.
x
))
RelReasoning
(
that
.
x
,
this
.
prop
&&
this
.
proof
&&
this
.
r
(
this
.
x
,
that
.
x
))
}
}
}
This diff is collapsed.
Click to expand it.
library/proof/package.scala
0 → 100644
+
59
−
0
View file @
24688442
/* Copyright 2009-2014 EPFL, Lausanne */
package
leon
import
leon.annotation._
import
leon.lang._
import
scala.language.implicitConversions
import
leon.proof.Internal._
package
object
proof
{
case
class
ProofOps
(
prop
:
Boolean
)
{
def
because
(
proof
:
Boolean
)
:
Boolean
=
proof
&&
prop
def
neverHolds
:
Boolean
=
{
require
(!
prop
)
!
prop
}
}
implicit
def
boolean2ProofOps
(
prop
:
Boolean
)
:
ProofOps
=
ProofOps
(
prop
)
def
trivial
:
Boolean
=
true
def
by
(
proof
:
Boolean
)(
prop
:
Boolean
)
:
Boolean
=
proof
&&
prop
def
check
(
prop
:
Boolean
)
:
Boolean
=
{
require
(
prop
)
prop
}
/**
* Relational reasoning.
*
* {
* ((y :: ys) :+ x).last ^^ _ == _ ^^| trivial |
* (y :: (ys :+ x)).last ==| trivial |
* (ys :+ x).last ==| snocLast(ys, x) |
* x
* }.qed
*/
case
class
RelReasoning
[
A
](
x
:
A
,
prop
:
Boolean
)
{
def
^^
[
B
](
r
:
(
A
,
B
)
=>
Boolean
)
:
WithRel
[
A
,
B
]
=
WithRel
(
x
,
r
,
prop
)
/** Short-hand for equational reasoning. */
def
==|
(
proof
:
Boolean
)
:
WithProof
[
A
,
A
]
=
{
require
(
proof
)
WithProof
(
x
,
_
==
_
,
proof
,
prop
)
}
def
qed
:
Boolean
=
prop
}
implicit
def
any2RelReasoning
[
A
](
x
:
A
)
:
RelReasoning
[
A
]
=
RelReasoning
(
x
,
true
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment