Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lisa
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
lisa
Commits
850ff7e6
Verified
Commit
850ff7e6
authored
3 years ago
by
Florian Cassayre
Browse files
Options
Downloads
Patches
Plain Diff
Fix the indenting of imports in the printer
parent
78cfcc81
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!3
Proof judgement ADT, sugars and printer
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/lisa/kernel/Printer.scala
+21
-10
21 additions, 10 deletions
src/main/scala/lisa/kernel/Printer.scala
with
21 additions
and
10 deletions
src/main/scala/lisa/kernel/Printer.scala
+
21
−
10
View file @
850ff7e6
...
@@ -180,6 +180,17 @@ object Printer {
...
@@ -180,6 +180,17 @@ object Printer {
Seq
(
prettyFormulas
(
sequent
.
left
),
"⊢"
,
prettyFormulas
(
sequent
.
right
)).
filter
(
_
.
nonEmpty
).
mkString
(
spaceSeparator
(
compact
))
Seq
(
prettyFormulas
(
sequent
.
left
),
"⊢"
,
prettyFormulas
(
sequent
.
right
)).
filter
(
_
.
nonEmpty
).
mkString
(
spaceSeparator
(
compact
))
}
}
/**
* Returns a string representation of the line number in a proof.
* Example output:
* <pre>
* 0:2:1
* </pre>
* @param line the line number
* @return the string representation of this line number
*/
def
prettyLineNumber
(
line
:
Seq
[
Int
])
:
String
=
line
.
mkString
(
":"
)
/**
/**
* Returns a string representation of this proof.
* Returns a string representation of this proof.
* @param proof the proof
* @param proof the proof
...
@@ -187,14 +198,13 @@ object Printer {
...
@@ -187,14 +198,13 @@ object Printer {
* (`->`) as an error. The proof is considered to be valid by default
* (`->`) as an error. The proof is considered to be valid by default
* @return a string where each indented line corresponds to a step in the proof
* @return a string where each indented line corresponds to a step in the proof
*/
*/
def
prettySCProof
(
proof
:
SCProof
,
judgement
:
SCProofCheckerJudgement
=
SCValidProof
)
:
String
=
{
def
prettySCProof
(
proof
:
SCProof
,
judgement
:
SCProofCheckerJudgement
=
SCValidProof
,
forceDisplaySubproofs
:
Boolean
=
false
)
:
String
=
{
def
computeMaxNumbering
(
proof
:
SCProof
,
level
:
Int
,
result
:
IndexedSeq
[
Int
])
:
IndexedSeq
[
Int
]
=
{
def
computeMaxNumbering
Lengths
(
proof
:
SCProof
,
level
:
Int
,
result
:
IndexedSeq
[
Int
])
:
IndexedSeq
[
Int
]
=
{
val
resultWithCurrent
=
result
.
updated
(
level
,
Math
.
max
(
proof
.
steps
.
size
-
1
,
result
(
level
))
)
val
resultWithCurrent
=
result
.
updated
(
level
,
(
Seq
(
(
proof
.
steps
.
size
-
1
).
toString
.
length
,
result
(
level
))
++
(
if
(
proof
.
imports
.
nonEmpty
)
Seq
((-
proof
.
imports
.
size
).
toString
.
length
)
else
Seq
.
empty
)).
max
)
proof
.
steps
.
collect
{
case
sp
:
SCSubproof
=>
sp
}.
foldLeft
(
resultWithCurrent
)((
acc
,
sp
)
=>
computeMaxNumbering
(
sp
.
sp
,
level
+
1
,
if
(
acc
.
size
<=
level
+
1
)
acc
:+
0
else
acc
))
proof
.
steps
.
collect
{
case
sp
:
SCSubproof
=>
sp
}.
foldLeft
(
resultWithCurrent
)((
acc
,
sp
)
=>
computeMaxNumbering
Lengths
(
sp
.
sp
,
level
+
1
,
if
(
acc
.
size
<=
level
+
1
)
acc
:+
0
else
acc
))
}
}
val
maxNumbering
=
computeMaxNumbering
(
proof
,
0
,
IndexedSeq
(
0
))
// The maximum value for each number column
val
maxNumberingLengths
=
computeMaxNumberingLengths
(
proof
,
0
,
IndexedSeq
(
0
))
// The maximum value for each number column
val
maxNumberingLengths
=
maxNumbering
.
map
(
_
.
toString
.
length
)
val
maxLevel
=
maxNumberingLengths
.
size
-
1
val
maxLevel
=
maxNumbering
.
size
-
1
def
leftPadSpaces
(
v
:
Any
,
n
:
Int
)
:
String
=
{
def
leftPadSpaces
(
v
:
Any
,
n
:
Int
)
:
String
=
{
val
s
=
String
.
valueOf
(
v
)
val
s
=
String
.
valueOf
(
v
)
...
@@ -239,7 +249,8 @@ object Printer {
...
@@ -239,7 +249,8 @@ object Printer {
prettySequent
(
step
.
bot
)
prettySequent
(
step
.
bot
)
)
)
step
match
{
step
match
{
case
sp
@
SCSubproof
(
_
,
_
,
true
)
=>
pretty
(
"Subproof"
,
sp
.
premises
*)
+:
prettySCProofRecursive
(
sp
.
sp
,
level
+
1
,
currentTree
,
(
if
(
i
==
0
)
topMostIndices
else
IndexedSeq
.
empty
)
:+
i
)
case
sp
@
SCSubproof
(
_
,
_
,
display
)
if
display
||
forceDisplaySubproofs
=>
pretty
(
"Subproof"
,
sp
.
premises
*)
+:
prettySCProofRecursive
(
sp
.
sp
,
level
+
1
,
currentTree
,
(
if
(
i
==
0
)
topMostIndices
else
IndexedSeq
.
empty
)
:+
i
)
case
other
=>
case
other
=>
val
line
=
other
match
{
val
line
=
other
match
{
case
Rewrite
(
_
,
t1
)
=>
pretty
(
"Rewrite"
,
t1
)
case
Rewrite
(
_
,
t1
)
=>
pretty
(
"Rewrite"
,
t1
)
...
@@ -268,7 +279,7 @@ object Printer {
...
@@ -268,7 +279,7 @@ object Printer {
case
RightSubstIff
(
_
,
t1
,
_
,
_
,
_
,
_
)
=>
pretty
(
"R. SubstIff"
,
t1
)
case
RightSubstIff
(
_
,
t1
,
_
,
_
,
_
,
_
)
=>
pretty
(
"R. SubstIff"
,
t1
)
case
InstFunSchema
(
_
,
t1
,
_
,
_
,
_
)
=>
pretty
(
"?Fun Instantiation"
,
t1
)
case
InstFunSchema
(
_
,
t1
,
_
,
_
,
_
)
=>
pretty
(
"?Fun Instantiation"
,
t1
)
case
InstPredSchema
(
_
,
t1
,
_
,
_
,
_
)
=>
pretty
(
"?Pred Instantiation"
,
t1
)
case
InstPredSchema
(
_
,
t1
,
_
,
_
,
_
)
=>
pretty
(
"?Pred Instantiation"
,
t1
)
case
SCSubproof
(
_
,
_
,
false
)
=>
pretty
(
"
SC
Subproof (hidden)"
)
case
SCSubproof
(
_
,
_
,
false
)
=>
pretty
(
"Subproof (hidden)"
)
case
other
=>
throw
new
Exception
(
s
"No available method to print this proof step, consider updating Printer.scala\n$other"
)
case
other
=>
throw
new
Exception
(
s
"No available method to print this proof step, consider updating Printer.scala\n$other"
)
}
}
Seq
(
line
)
Seq
(
line
)
...
@@ -288,7 +299,7 @@ object Printer {
...
@@ -288,7 +299,7 @@ object Printer {
full
.
mkString
(
" "
)
full
.
mkString
(
" "
)
}.
mkString
(
"\n"
)
+
(
judgement
match
{
}.
mkString
(
"\n"
)
+
(
judgement
match
{
case
SCValidProof
=>
""
case
SCValidProof
=>
""
case
SCInvalidProof
(
path
,
message
)
=>
s
"\nProof checker has reported error at line ${path.mkString("
.
")}: $message"
case
SCInvalidProof
(
path
,
message
)
=>
s
"\nProof checker has reported
an
error at line ${path.mkString("
.
")}: $message"
})
})
}
}
...
...
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