Skip to content
Snippets Groups Projects
Unverified Commit 712da949 authored by Sankalp Gambhir's avatar Sankalp Gambhir Committed by GitHub
Browse files

Dependency and Scala Upgrades (#221)

* More sensible multi line strings, up scalafmt version

* Upgrade sbt version

* Upgrade sbt plugins

* Upgrade Scala version to 3.3.3

* Update library dependencies

* Expose library main classes

* Remove infinite loop (?)

* Uncomment examples, move Goeland examples to separate object

* Scala fmt

* Comment SimpleTautology
parent cbec1558
No related branches found
No related tags found
No related merge requests found
version = 3.4.2 version = 3.7.13
runner.dialect = scala3 runner.dialect = scala3
...@@ -8,4 +8,7 @@ docstrings.style = Asterisk ...@@ -8,4 +8,7 @@ docstrings.style = Asterisk
docstrings.oneline = unfold docstrings.oneline = unfold
docstrings.wrap = no docstrings.wrap = no
align.preset = none # align and indentation settings
\ No newline at end of file align.preset = none
assumeStandardLibraryStripMargin = true
align.stripMargin = true
...@@ -14,19 +14,14 @@ ThisBuild / scalacOptions ++= Seq( ...@@ -14,19 +14,14 @@ ThisBuild / scalacOptions ++= Seq(
ThisBuild / javacOptions ++= Seq("-encoding", "UTF-8") ThisBuild / javacOptions ++= Seq("-encoding", "UTF-8")
ThisBuild / semanticdbEnabled := true ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision ThisBuild / semanticdbVersion := scalafixSemanticdb.revision
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0"
val commonSettings = Seq( val commonSettings = Seq(
crossScalaVersions := Seq("3.3.1"), crossScalaVersions := Seq("3.3.3"),
run / fork := true run / fork := true
) )
val scala2 = "2.13.8" val scala2 = "2.13.8"
val scala3 = "3.3.1" val scala3 = "3.3.3"
val commonSettings2 = commonSettings ++ Seq( val commonSettings2 = commonSettings ++ Seq(
scalaVersion := scala2, scalaVersion := scala2,
...@@ -36,15 +31,10 @@ val commonSettings3 = commonSettings ++ Seq( ...@@ -36,15 +31,10 @@ val commonSettings3 = commonSettings ++ Seq(
scalaVersion := scala3, scalaVersion := scala3,
scalacOptions ++= Seq( scalacOptions ++= Seq(
"-language:implicitConversions", "-language:implicitConversions",
// "-source:future", re-enable when liancheng/scalafix-organize-imports#221 is fixed
), ),
javaOptions += "-Xmx10G", javaOptions += "-Xmx10G",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test", libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.18" % "test",
libraryDependencies += "com.lihaoyi" %% "sourcecode" % "0.3.0", libraryDependencies += "com.lihaoyi" %% "sourcecode" % "0.4.1",
//libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1",
// libraryDependencies += ("io.github.uuverifiers" %% "princess" % "2023-06-19").cross(CrossVersion.for3Use2_13),
Test / parallelExecution := false Test / parallelExecution := false
) )
...@@ -63,12 +53,14 @@ silex/scalacOptions ~= (_.filterNot(Set("-Wvalue-discard"))) ...@@ -63,12 +53,14 @@ silex/scalacOptions ~= (_.filterNot(Set("-Wvalue-discard")))
lazy val root = Project( lazy val root = Project(
id = "lisa", id = "lisa",
base = file(".") base = file("."),
) )
.settings(commonSettings3) .settings(commonSettings3)
.dependsOn(kernel, withTests(utils), withTests(sets)) // Everything but `examples` .dependsOn(kernel, withTests(utils), withTests(sets)) // Everything but `examples`
.aggregate(utils) // To run tests on all modules .aggregate(utils) // To run tests on all modules
Compile / run := (sets / Compile / run).evaluated
lazy val kernel = Project( lazy val kernel = Project(
id = "lisa-kernel", id = "lisa-kernel",
base = file("lisa-kernel") base = file("lisa-kernel")
......
...@@ -46,12 +46,12 @@ object ADTExample extends lisa.Main { ...@@ -46,12 +46,12 @@ object ADTExample extends lisa.Main {
show(nil.intro) show(nil.intro)
show(cons.intro) show(cons.intro)
Lemma(nil(A) :: list(A)){ Lemma(nil(A) :: list(A)) {
have(thesis) by TypeChecker.prove have(thesis) by TypeChecker.prove
} }
Lemma((x :: A, l :: list(A)) |- cons(A) * x * l :: list(A)){ Lemma((x :: A, l :: list(A)) |- cons(A) * x * l :: list(A)) {
have(thesis) by TypeChecker.prove have(thesis) by TypeChecker.prove
} }
// Induction // Induction
show(list.induction) show(list.induction)
...@@ -69,12 +69,11 @@ object ADTExample extends lisa.Main { ...@@ -69,12 +69,11 @@ object ADTExample extends lisa.Main {
} }
val pred = fun(nat, nat): val pred = fun(nat, nat):
Case(zero): Case(zero):
zero zero
Case(succ, n): Case(succ, n):
n n
// ************************ // ************************
// * 4 : Induction Tactic * // * 4 : Induction Tactic *
// ************************ // ************************
...@@ -103,16 +102,16 @@ object ADTExample extends lisa.Main { ...@@ -103,16 +102,16 @@ object ADTExample extends lisa.Main {
val typeNil = have(nil(A) :: list(A)) by TypeChecker.prove val typeNil = have(nil(A) :: list(A)) by TypeChecker.prove
val typeCons = have((y :: A, l :: list(A)) |- cons(A) * y * l :: list(A)) by TypeChecker.prove val typeCons = have((y :: A, l :: list(A)) |- cons(A) * y * l :: list(A)) by TypeChecker.prove
have(l :: list(A) |- forall(x, x :: A ==> !(l === cons(A) * x * l))) by Induction(){ have(l :: list(A) |- forall(x, x :: A ==> !(l === cons(A) * x * l))) by Induction() {
Case(nil) subproof { Case(nil) subproof {
have(x :: A ==> !(nil(A) === cons(A) * x * nil(A))) by Tautology.from(list.injectivity(nil, cons) of (y0 := x, y1 := nil(A)), typeNil) have(x :: A ==> !(nil(A) === cons(A) * x * nil(A))) by Tautology.from(list.injectivity(nil, cons) of (y0 := x, y1 := nil(A)), typeNil)
thenHave(forall(x, x :: A ==> !(nil(A) === cons(A) * x * nil(A)))) by RightForall thenHave(forall(x, x :: A ==> !(nil(A) === cons(A) * x * nil(A)))) by RightForall
} }
Case(cons, y, l) subproof { Case(cons, y, l) subproof {
have((y :: A ==> !(l === cons(A) * y * l), y :: A, l :: list(A)) |- x :: A ==> !(cons(A) * y * l === cons(A) * x * (cons(A) * y * l))) by Tautology.from( have((y :: A ==> !(l === cons(A) * y * l), y :: A, l :: list(A)) |- x :: A ==> !(cons(A) * y * l === cons(A) * x * (cons(A) * y * l))) by Tautology.from(
cons.injectivity of (x0 := y, x1 := l, y0 := x, y1 := cons(A) * y * l), cons.injectivity of (x0 := y, x1 := l, y0 := x, y1 := cons(A) * y * l),
typeCons typeCons
) )
thenHave((y :: A ==> !(l === cons(A) * y * l), y :: A, l :: list(A)) |- forall(x, x :: A ==> !(cons(A) * y * l === cons(A) * x * (cons(A) * y * l)))) by RightForall thenHave((y :: A ==> !(l === cons(A) * y * l), y :: A, l :: list(A)) |- forall(x, x :: A ==> !(cons(A) * y * l === cons(A) * x * (cons(A) * y * l)))) by RightForall
thenHave((forall(x, x :: A ==> !(l === cons(A) * x * l)), y :: A, l :: list(A)) |- forall(x, x :: A ==> !(cons(A) * y * l === cons(A) * x * (cons(A) * y * l)))) by LeftForall thenHave((forall(x, x :: A ==> !(l === cons(A) * x * l)), y :: A, l :: list(A)) |- forall(x, x :: A ==> !(cons(A) * y * l === cons(A) * x * (cons(A) * y * l)))) by LeftForall
} }
...@@ -122,4 +121,4 @@ object ADTExample extends lisa.Main { ...@@ -122,4 +121,4 @@ object ADTExample extends lisa.Main {
thenHave(thesis) by Tautology thenHave(thesis) by Tautology
} }
} }
\ No newline at end of file
import lisa.automation.Congruence
import lisa.automation.Substitution.{ApplyRules as Substitute} import lisa.automation.Substitution.{ApplyRules as Substitute}
import lisa.automation.Tableau import lisa.automation.Tableau
import lisa.automation.atp.Goeland import lisa.automation.atp.Goeland
import lisa.automation.Congruence
object Example extends lisa.Main { object Example extends lisa.Main:
draft() draft()
val x = variable val x = variable
...@@ -62,91 +62,82 @@ object Example extends lisa.Main { ...@@ -62,91 +62,82 @@ object Example extends lisa.Main {
have(thesis) by Tableau have(thesis) by Tableau
} }
val buveurs2 = Theorem(exists(x, P(x) ==> forall(y, P(y)))) { // val a = variable
have(thesis) by Goeland//("goeland/Example.buveurs2_sol") // val one = variable
} // val two = variable
// val * = SchematicFunctionLabel("*", 2)
// val << = SchematicFunctionLabel("<<", 2)
val a = variable // val / = SchematicFunctionLabel("/", 2)
val one = variable // private val star: SchematicFunctionLabel[2] = *
val two = variable // private val shift: SchematicFunctionLabel[2] = <<
val * = SchematicFunctionLabel("*", 2) // private val divide: SchematicFunctionLabel[2] = /
val << = SchematicFunctionLabel("<<", 2)
val / = SchematicFunctionLabel("/", 2) // extension (t:Term) {
private val star: SchematicFunctionLabel[2] = * // def *(u:Term) = star(t, u)
private val shift: SchematicFunctionLabel[2] = << // def <<(u:Term) = shift(t, u)
private val divide: SchematicFunctionLabel[2] = / // def /(u:Term) = divide(t, u)
// }
while (true) { // val congruence = Theorem(((a*two) === (a<<one), a*(two/two) === (a*two)/two, (two/two) === one, (a*one) === a) |- ((a<<one)/two) === a) {
() // have(thesis) by Congruence
} // }
extension (t:Term) {
def *(u:Term) = star(t, u)
def <<(u:Term) = shift(t, u)
def /(u:Term) = divide(t, u)
}
val congruence = Theorem(((a*two) === (a<<one), a*(two/two) === (a*two)/two, (two/two) === one, (a*one) === a) |- ((a<<one)/two) === a) {
have(thesis) by Congruence
}
/*
import lisa.mathematics.settheory.SetTheory.*
// import lisa.mathematics.settheory.SetTheory.*
// Examples of definitions // Examples of definitions
val succ = DEF(x) --> union(unorderedPair(x, singleton(x))) // val succ = DEF(x) --> union(unorderedPair(x, singleton(x)))
show // show
val inductiveSet = DEF(x) --> in(∅, x) /\ forall(y, in(y, x) ==> in(succ(y), x))
show
*/ // val inductiveSet = DEF(x) --> in(∅, x) /\ forall(y, in(y, x) ==> in(succ(y), x))
// show
// Simple tactic definition for LISA DSL
// object SimpleTautology extends ProofTactic {
// def solveFormula(using proof: library.Proof)(f: Formula, decisionsPos: List[Formula], decisionsNeg: List[Formula]): proof.ProofTacticJudgement = {
// Simple tactic definition for LISA DSL // val redF = reducedForm(f)
/* // if (redF == ⊤) {
import lisa.automation.kernel.OLPropositionalSolver.* // Restate(decisionsPos |- f :: decisionsNeg)
// } else if (redF == ⊥) {
object SimpleTautology extends ProofTactic { // proof.InvalidProofTactic("Sequent is not a propositional tautology")
def solveFormula(using proof: library.Proof)(f: Formula, decisionsPos: List[Formula], decisionsNeg: List[Formula]): proof.ProofTacticJudgement = { // } else {
val redF = reducedForm(f) // val atom = findBestAtom(redF).get
if (redF == ⊤) { // def substInRedF(f: Formula) = redF.substituted(atom -> f)
Restate(decisionsPos |- f :: decisionsNeg) // TacticSubproof {
} else if (redF == ⊥) { // have(solveFormula(substInRedF(⊤), atom :: decisionsPos, decisionsNeg))
proof.InvalidProofTactic("Sequent is not a propositional tautology") // val step2 = thenHave(atom :: decisionsPos |- redF :: decisionsNeg) by Substitution2(⊤ <=> atom)
} else { // have(solveFormula(substInRedF(⊥), decisionsPos, atom :: decisionsNeg))
val atom = findBestAtom(redF).get // val step4 = thenHave(decisionsPos |- redF :: atom :: decisionsNeg) by Substitution2(⊥ <=> atom)
def substInRedF(f: Formula) = redF.substituted(atom -> f) // have(decisionsPos |- redF :: decisionsNeg) by Cut(step4, step2)
TacticSubproof { // thenHave(decisionsPos |- f :: decisionsNeg) by Restate
have(solveFormula(substInRedF(⊤), atom :: decisionsPos, decisionsNeg)) // }
val step2 = thenHave(atom :: decisionsPos |- redF :: decisionsNeg) by Substitution2(⊤ <=> atom) // }
have(solveFormula(substInRedF(⊥), decisionsPos, atom :: decisionsNeg)) // }
val step4 = thenHave(decisionsPos |- redF :: atom :: decisionsNeg) by Substitution2(⊥ <=> atom)
have(decisionsPos |- redF :: decisionsNeg) by Cut(step4, step2) // def solveSequent(using proof: library.Proof)(bot: Sequent) =
thenHave(decisionsPos |- f :: decisionsNeg) by Restate // TacticSubproof { // Since the tactic above works on formulas, we need an extra step to convert an arbitrary sequent to an equivalent formula
} // have(solveFormula(sequentToFormula(bot), Nil, Nil))
} // thenHave(bot) by Restate.from
} // }
// }
def solveSequent(using proof: library.Proof)(bot: Sequent) = // val a = formulaVariable
TacticSubproof { // Since the tactic above works on formulas, we need an extra step to convert an arbitrary sequent to an equivalent formula // val b = formulaVariable
have(solveFormula(sequentToFormula(bot), Nil, Nil)) // val c = formulaVariable
thenHave(bot) by Restate.from
}
}
*/
// val a = formulaVariable()
// val b = formulaVariable()
// val c = formulaVariable()
// val testTheorem = Lemma((a /\ (b \/ c)) <=> ((a /\ b) \/ (a /\ c))) { // val testTheorem = Lemma((a /\ (b \/ c)) <=> ((a /\ b) \/ (a /\ c))) {
// have(thesis) by SimpleTautology.solveSequent // have(thesis) by SimpleTautology.solveSequent
// } // }
// show // show
} /**
* Example showing discharge of proofs using the Goeland theorem prover. Will
* fail if Goeland is not available on PATH.
*/
object GoelandExample extends lisa.Main:
val x = variable
val y = variable
val P = predicate[1]
val f = function[1]
val buveurs2 = Theorem(exists(x, P(x) ==> forall(y, P(y)))) {
have(thesis) by Goeland // ("goeland/Example.buveurs2_sol")
}
...@@ -268,9 +268,9 @@ class ParserTest extends AnyFunSuite with TestUtils { ...@@ -268,9 +268,9 @@ class ParserTest extends AnyFunSuite with TestUtils {
FOLParser.parseFormula("f(x y)") FOLParser.parseFormula("f(x y)")
} catch { } catch {
case e: UnexpectedInputException => assert(e.getMessage.startsWith(""" case e: UnexpectedInputException => assert(e.getMessage.startsWith("""
|f(x y) |f(x y)
| ^ | ^
|Unexpected input""".stripMargin)) |Unexpected input""".stripMargin))
} }
} }
...@@ -280,9 +280,9 @@ class ParserTest extends AnyFunSuite with TestUtils { ...@@ -280,9 +280,9 @@ class ParserTest extends AnyFunSuite with TestUtils {
} catch { } catch {
case e: UnexpectedInputException => case e: UnexpectedInputException =>
assert(e.getMessage.startsWith(""" assert(e.getMessage.startsWith("""
|x = (a /\ b) |x = (a /\ b)
| ^^^^^^ | ^^^^^^
|Unexpected input: expected term""".stripMargin)) |Unexpected input: expected term""".stripMargin))
} }
} }
} }
sbt.version = 1.9.3 sbt.version = 1.9.9
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.1.0") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.2.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.34") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment