Skip to content

Commit

Permalink
Manual (#179)
Browse files Browse the repository at this point in the history
* Starting a layer of abstraction.

* swrdgv

* sedgf

* ONgoing work. FOL structure mostly implemented, substitutions ongoing.

* continued

* further changes

* LisaObject has a self type being self

* More improvements on substitution

* More work

* multivar substitution

* improvements to MapProofTest

* finished fol, need to do prooflib

* started work on prooflib, cut plenty unused code in Library.scala

* more work on substitutions

* updated WithTheorems

* finished BasicSteptactics and substitutions

* more corrections of tactics using unifier

* fixed F and K imports

* finished PrrofHelpers and definitions. Definitions possibly not final

* Done most of the simpleDeducedSteps

* ongoing work on types

* added doc in Common.scala

* more doc, some simplification

* more doc and simplification of unneeded parts

* fixed some export issues. Commented some tests. translation left for the future.

* remove some debug code

* add missing files

* continue F integration. FInished with Set theory library files, now doing CommonTactics.scala (part is Dario's work).

* simplifier remaining

* renaming and mroe compatibility

* more adaptations

* merge build.sbt

* fixing

* transforming unification to Front

* weird issues with match types and dotty

* Compiles..? Need to simplify use of Arity in formula labels now. Finger crossed.

* add missing files

* still compiles

* Term**0 |-> Term

* Does not compile (dotty crash). Possibly due to covariant schematic labels.

* Labels are contravariant

* Weird "inherits conflicting instances of non-variant base trait LisaObject"

* structure seems to work; Constant extends ConstantFunctionSymbol[0], issue with case class (has to reimplement).

* back to the "common super type with case classes" structure

* finished predicates, compiles. Connector left

* Finished datastructure. TODO: Underlyings, Arity, uncomment asFront

* Compiles, checked arity and underlyings (mostly)

* Rehabilited asFront. Next stop, Substitution.

* porting unificationUtils

* half of unificationUtils done. Need to make Common even closer structure to kernel (variableFormula extends PredicateFormula)

* progress through unification

* compiles, progressing

* safe for reset

* only applySubst remaining.
Note: given
```scala
val s: Seq[(Variable, Term)]
```
`s.toMap` crashes dotty. Instead, do `Map(s*)`.

* Substitution done, everything compiles.

* rehabilited commented function

* utils tests compiles and pass.

* Finished setTheorzLibrary, close to finish OLPropositionalSolver

* Quantifiers.scala work, completed BasicProofTactic, implemented printing of terms and formulas

* progress on compilation and run of SetTheory.scala

* ordinals1 works

* Everything works, even example package. Some tests are still commentated. Simplified a couple proofs.

* Small improvements

* Ready for demo

* scalafix, scalafmt

* git add

* Add a Quick User Guide as chapter 1 of the reference manual

* small changes to manual

* update colors and date

* git add quickguide.tex

* small manual update

* Add a section on special characters (unicode and ligatures), spellcheck.
  • Loading branch information
SimonGuilloud authored Oct 5, 2023
1 parent 265ed45 commit 49d235f
Show file tree
Hide file tree
Showing 12 changed files with 1,017 additions and 578 deletions.
12 changes: 6 additions & 6 deletions Reference Manual/kernel.tex
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ \subsection{Syntax}
In this document, as well as in the code documentation, we often write terms and formulas in a more conventional way, generally hiding the arity of labels and representing the label with its identifier only, preceded by an apostrophe (\lstinline|`|) if we need to precise that a symbol is schematic. When the arity is relevant, we write it with a superscript, for example:
%
\begin{gather*}
f^3(x,,z) \equiv \operatorname{Fun}(f, 3)(\List(\Var(x), \Var(y), \Var(z)))~,
f^3(x,y,z) \equiv \operatorname{Fun}(f, 3)(\List(\Var(x), \Var(y), \Var(z)))~,
\end{gather*}
%
and
Expand Down Expand Up @@ -287,7 +287,7 @@ \subsection{The Equivalence Checker}
For soundness, the relation decided by the algorithm should be contained in the $\iff$ ``if and only if'' relation of first order logic. However, it is well known that this relationship is in general undecidable, and even the $\iff$ relation for propositional logic is coNP-complete. For practicality, we need a relation that is efficiently computable.

The decision procedure implemented in LISA takes time quadratic in the size of the formula, which means that it is not significantly slower than syntactic equality.
It is based on an algorithm that decides the word problem for Ortholattices \cite{guilloudFormulaNormalizationsVerification2023a}.
It is based on an algorithm that decides the word problem for Ortholattices \cite{guilloudFormulaNormalizationsVerification2023}.
Ortholattices are a generalization of Boolean algebra where instead of the law of distributivity, the weaker absorption law (L9, \autoref{tab:ortholatticeLaws}) holds. In particular, every identity in the theory of ortholattices is also a theorem of propositional logic.
\begin{table}[bth]
\centering
Expand All @@ -314,7 +314,7 @@ \subsection{The Equivalence Checker}
We write $s\sim_\OL t$ if both $s\leq_\OL t$ and $s\geq_\OL t$ hold.
\autoref{thm:OL} is the main result we rely on.

\begin{theorem}[\cite{guilloudFormulaNormalizationsVerification2023a}]
\begin{theorem}[\cite{guilloudFormulaNormalizationsVerification2023}]
\label{thm:OL}
There exists an algorithm running in worst case quadratic time producing, for any terms $s$ over the signature $(\land, \lor, \neg)$, a normal form $\text{NF}_{\OL}(s)$
such that for any $t$, $s \sim_\OL t$ if and only if $\text{NF}_{\OL}(s) = \text{NF}_{\OL}(t)$. The algorithm is also capable of deciding if $s \leq_{OL} t$ holds in quadratic time.
Expand Down Expand Up @@ -345,7 +345,7 @@ \subsection{The Equivalence Checker}


In particular, the implementation in LISA also takes into account symmetry and reflexivity of equality as well as alpha-equivalence, by which we mean renaming of bound variables. It also expresses $\rightarrow$ and $\leftrightarrow$ in terms of $\lor$ and $\land$.
A more detailed discussion of extension of ortholattices to first-order logic, proof of correctness and implementation details can be found in \cite{guilloudFormulaNormalizationsVerification2023a} and \cite{guilloudLISAModernProof2023a}.
A more detailed discussion of extension of ortholattices to first-order logic, proof of correctness and implementation details can be found in \cite{guilloudFormulaNormalizationsVerification2023} and \cite{guilloudLISAModernProof2023}.



Expand All @@ -354,7 +354,7 @@ \section{Proofs in Sequent Calculus}
\label{sec:proofs_lk}
\subsection{Sequent Calculus}
\label{subsec:lk}
The deductive system used by LISA is an extended version of Gentzen's Sequent Calculus \cite{Gentzen1935,Gentzen1935II}.
The deductive system used by LISA is an extended version of the classical Sequent Calculus.
%
\begin{definition}
A \textbf{sequent} is a pair $(\Gamma, \Sigma)$ of (possibly empty) sets of formulas, noted:
Expand Down Expand Up @@ -1086,5 +1086,5 @@ \subsection{How to write helpers}
%
Now, every time a \lstinline|TermLabel| is writen in a place where a \lstinline|Term| is expected, it will be converted implicitly.

To learn more about Scala 3 and its capabilities, see its documentation at \footnotesize{\url{https://docs.scala-lang.org/scala3/book/introduction.html}}.
To learn more about Scala 3 and its capabilities, see its documentation at {\footnotesize\url{https://docs.scala-lang.org/scala3/book/introduction.html}}.

Binary file modified Reference Manual/lisa.pdf
Binary file not shown.
10 changes: 7 additions & 3 deletions Reference Manual/lisa.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
\author{Simon Guilloud\\Laboratory for Automated Reasoning and Analysis, EPFL}
\date{}

\begin{document}
\begin{document}

\newfontfamily\titlefont{Arial}

Expand All @@ -23,11 +23,13 @@

\vspace{1.5cm}

\textbf{\large WIP Edition}
\textbf{\large Version 0.2.1}

\textbf{\large \today}

\vspace{1.5cm}

{\Large Laboratory for Automated Reasoning and Analysis, EPFL, Switzerland}
{\Large Laboratory for Automated Reasoning and Analysis\\ EPFL, Switzerland}

\vspace{1.5cm}

Expand All @@ -50,6 +52,8 @@ \chapter*{Introduction}

\tableofcontents

\input{quickguide.tex}

\input{kernel.tex}

\input{prooflib.tex}
Expand Down
86 changes: 78 additions & 8 deletions Reference Manual/macro.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% macro.tex

\usepackage[utf8]{inputenc}
%\usepackage[utf8]{inputenc}
\usepackage{url}
\usepackage{graphicx}
\usepackage[english]{babel}
Expand All @@ -12,7 +12,7 @@
\usepackage[dvipsnames]{xcolor}
\usepackage{csquotes}
\usepackage[strings]{underscore}
\usepackage{hyperref}
\usepackage{hyperref}
\usepackage{bussproofs}
\usepackage{makecell}
\usepackage{subcaption}
Expand All @@ -21,8 +21,8 @@
\usepackage{xspace}
\usepackage[ruled,vlined]{algorithm2e}
\usepackage{array}
\usepackage{arial}
\usepackage[T1]{fontenc}
\usepackage{newunicodechar} %To map unicode in listings to a different font than Fira Code
\renewcommand\sfdefault{ua1}
\sloppy % better (?) margin handling

Expand All @@ -44,13 +44,58 @@
\newcommand*{\definitionautorefname}{Definition}


% URLs

%Code
%\usepackage[nomap]{FiraMono}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=blue,
pdftitle={LISA Reference Manual},
pdfpagemode=FullScreen,
}
\urlstyle{same}



% Code fonts

%\usepackage{lstfiracode}
\usepackage{fontspec}
\usepackage{ucharclasses}
\setmonofont[
Contextuals={Alternate}
]{Fira Code}
\newfontfamily{\fallbackfont}{DejaVuSans}
\DeclareTextFontCommand{\textfallback}{\fallbackfont}
\newunicodechar{∀}{\textfallback{∀}}
\newunicodechar{∃}{\textfallback{∃}}
\newunicodechar{∅}{\textfallback{∅}}
\newunicodechar{⊆}{\textfallback{⊆}}
\newunicodechar{∈}{\textfallback{∈}}


% Correct lstlisting parsing of unicode character. Add unicode points at the end.
\makeatletter
\lst@InputCatcodes
\def\lst@DefEC{%
\lst@CCECUse \lst@ProcessLetter
^^80^^81^^82^^83^^84^^85^^86^^87^^88^^89^^8a^^8b^^8c^^8d^^8e^^8f%
^^90^^91^^92^^93^^94^^95^^96^^97^^98^^99^^9a^^9b^^9c^^9d^^9e^^9f%
^^a0^^a1^^a2^^a3^^a4^^a5^^a6^^a7^^a8^^a9^^aa^^ab^^ac^^ad^^ae^^af%
^^b0^^b1^^b2^^b3^^b4^^b5^^b6^^b7^^b8^^b9^^ba^^bb^^bc^^bd^^be^^bf%
^^c0^^c1^^c2^^c3^^c4^^c5^^c6^^c7^^c8^^c9^^ca^^cb^^cc^^cd^^ce^^cf%
^^d0^^d1^^d2^^d3^^d4^^d5^^d6^^d7^^d8^^d9^^da^^db^^dc^^dd^^de^^df%
^^e0^^e1^^e2^^e3^^e4^^e5^^e6^^e7^^e8^^e9^^ea^^eb^^ec^^ed^^ee^^ef%
^^f0^^f1^^f2^^f3^^f4^^f5^^f6^^f7^^f8^^f9^^fa^^fb^^fc^^fd^^fe^^ff%
^^^^2200^^^^2203^^^^2205^^^^2286^^^^2208% <--- for ∀
^^00}
\lst@RestoreCatcodes
\makeatother


% Syntactic coloring


\makeatletter
\def\verbatim@nolig@list{}
Expand All @@ -61,10 +106,13 @@
\definecolor{comments}{RGB}{80,0,110}

\lstdefinelanguage{scala}{
extendedchars = true,
inputencoding = utf8,
alsoletter={@,=,>},
keywordstyle = {\color{blue}},
keywordstyle = [2]{\color{blue}},
commentstyle = \color{comments},
basicstyle=\footnotesize\linespread{1.15}\ttfamily,
morekeywords = [2]{abstract, case, class, def, do, Input, Output, then,
else, extends, false, free, if, implicit, match,
object, true, val, var, while, sealed, or,
Expand All @@ -81,12 +129,15 @@
}

\lstdefinelanguage{lisa}{
extendedchars = true,
inputencoding = utf8,
alsoletter={@,=,>},
keywordstyle = {\color{blue}},
keywordstyle = [2]{\color{blue}},
keywordstyle = [3]{\color{green}},
keywordstyle = [4]{\color{teal}},
commentstyle = \color{comments},
basicstyle=\footnotesize\linespread{1.15}\ttfamily,
morekeywords = [2]{abstract, case, class, def, do, Input, Output, then,
else, extends, false, free, if, implicit, match,
object, true, val, var, while, sealed, or,
Expand All @@ -104,15 +155,34 @@
}


\definecolor{rosishlightgray}{rgb}{0.96, 0.94, 0.92}
\definecolor{bluishlightgray}{rgb}{0.94, 0.96, 0.98}

\lstdefinelanguage{console}{
extendedchars = true,
inputencoding = utf8,
backgroundcolor = \color{bluishlightgray},
basicstyle=\footnotesize\linespread{1.15}\ttfamily,
mathescape,
escapeinside={!*}{*!},
columns=fullflexible,
morekeywords={if,then,else,return,match,with,end,let,in, data, type, :=, def},
moredelim=**[is][\color{green}]{@*}{*@},
moredelim=**[is][\color{red}]{@**}{**@},
}

\definecolor{verylightgray}{rgb}{0.96, 0.94, 0.92}
\lstset{
backgroundcolor = \color{verylightgray},
extendedchars = true,
inputencoding = utf8,
extendedchars = \true,
backgroundcolor = \color{rosishlightgray},
basicstyle=\footnotesize\linespread{1.15}\ttfamily,
mathescape,
escapeinside={!*}{*!},
columns=fullflexible,
morekeywords={if,then,else,return,match,with,end,let,in, data, type, :=, def}
morekeywords={if,then,else,return,match,with,end,let,in, data, type, :=, def},
moredelim=**[is][\color{green}]{@*}{*@},
moredelim=**[is][\color{red}]{@**}{**@},
}

\DeclareMathOperator{\pick}{pick}
Expand Down
122 changes: 37 additions & 85 deletions Reference Manual/prooflib.tex
Original file line number Diff line number Diff line change
@@ -1,99 +1,51 @@
\chapter{Developping Mathematics with Prooflib}

\section{Writing theory files}
LISA provides a canonical way of writing and organizing Kernel proofs by mean of a set of utilities and a DSL made possible by some of Scala 3's features such as string interpolation, extension and implicits.
The way to write a new theory file to mathematical development is:
\begin{lstlisting}[language=Scala, frame=single]
\label{chapt:prooflib}
LISA's kernel offers all the necessary tools to develops proofs, but reading and writing proofs written directly in its language is cumbersome.
To develop and maintain a library of mathematical development, LISA offers a dedicate interface and DSL to write proofs: Prooflib
LISA provides a canonical way of writing and organizing Kernel proofs by mean of a set of utilities and a DSL made possible by some of Scala 3's features.
\autoref{fig:theoryFileExample} is a reminder from \autoref{chapt:quickguide} of the canonical way to write a theory file in LISA.

\begin{figure}
\begin{lstlisting}[language=lisa, frame=single]
object MyTheoryName extends lisa.Main {

}
\end{lstlisting}
and that's it! To write a theorem, the recommended syntax is:

\begin{lstlisting}[language=Scala, frame=single]
object MyTheoryName extends lisa.Main {

THEOREM("theoremName") of "desired conclusion" PROOF {

???: Proof

} using (listOfJustifications)
show
}
\end{lstlisting}
\lstinline|show|{} is optional and prints the last proven theorem. We can similarily make the definition:

% avoid page breaking
\noindent
\begin{minipage}{\textwidth}
\begin{lstlisting}[language=Scala, frame=single]
object MyTheoryName extends lisa.Main {

val myFunction =
DEFINE("symbol", x, y) as definition(x,y)
show
val x = variable
val f = function[1]
val P = predicate[1]

val fixedPointDoubleApplication = Theorem(
∀(x, P(x) ==> P(f(x))) |- P(x) ==> P(f(f(x)))
) {
assume(∀(x, P(x) ==> P(f(x))))
val step1 = have(P(x) ==> P(f(x))) by InstantiateForall
val step2 = have(P(f(x)) ==> P(f(f(x)))) by InstantiateForall
have(thesis) by Tautology.from(step1, step2)
}


val emptySetIsASubset = Theorem(
∅ ⊆ x
) {
have((y ∈ ∅) ==> (y ∈ x)) by Tautology.from(
emptySetAxiom of (x := y))
val rhs = thenHave (∀(y, (y ∈ ∅) ==> (y ∈ x))) by RightForall
have(thesis) by Tautology.from(
subsetAxiom of (x := ∅, y := x), rhs)
}
\end{lstlisting}
\end{minipage}
%
This works for definitions of function and predicate symbols with a direct definition. for indirect definitions (via $\exists !$), use the following:
%
\begin{lstlisting}[language=Scala, frame=single]
object MyTheoryName extends lisa.Main {

val testdef =
DEFINE("symbol", x, y) asThe z suchThat {
???:Formula
} PROOF {
???:Proof
} using (listOfJustifications)
show
}
\end{lstlisting}
\caption{An example of a theory file in LISA}
\label{fig:theoryFileExample}
\end{figure}

In this chapter, we will describe how each of these construct is made possible and how they translate to statements in the Kernel.

=======
It is important to note that when multiple such files are developed, they all use the same underlying \lstinline|RunningTheory|{}. This makes it possible to use results proved previously by means of a simple \lstinline|import|{} statement as one would import a regular object. Similarly, one should also import as usual automation and tactics developed alongside. It is expected in the medium term that \lstinline|lisa.Main|{} will come with basic automation.

To check the result of a developed file, and verify that the proofs contain no error, it is possible to run such a library object.
% specify which object
All imported theory objects will be run through as well, but only the result of the selected one will be printed.
\section*{WIP}

It is possible to refer to a theorem or axiom that has been previously proven or added using its name. The syntax is \lstinline|thm``theoremName''|{} or \lstinline|ax``axiomName''|{}. This makes it possible to write, for example, \lstinline|thm``theoremName''.show|{} and \lstinline|... using (ax``comprehensionSchema'')| Figure \ref{fig:kernellibrary} shows a typical example of set theory development.
%It is important to note that when multiple such files are developed, they all use the same underlying \lstinline|RunningTheory|{}. This makes it possible to use results proved previously by means of a simple \lstinline|import|{} statement as one would import a regular object. Similarly, one should also import as usual automation and tactics developed alongside. It is expected in the medium term that \lstinline|lisa.Main|{} will come with basic automation.
%All imported theory objects will be run through as well, but only the result of the selected one will be printed.


\begin{figure}[hp]
\begin{lstlisting}[language=Scala, frame=single]
object MyTheoryName extends lisa.Main {
THEOREM("russelParadox") of
(*@ $\forall$ @*)x. (x(*@$\in$@*)?y)(*@$\leftrightarrow$@*) (*@$\neg$@*)(x(*@$\in$@*)x)(*@$\vdash$@*) PROOF {
val y = VariableLabel("y")
val x = VariableLabel("x")
val s0 = RewriteTrue(in(y, y) <=> !in(y, y) |-())
val s1 = LeftForall(
forall(x, in(x, y) <=> !in(x, x)) |- (),
0, in(x, y) <=> !in(x, x), x, y
)
Proof(s0, s1)
} using ()
thm"russelParadox".show


THEOREM("unorderedPair_symmetry") of
"(*@$\vdash$@*)(*@$\forall$@*)y, x. {x, y} = {y, x}" PROOF {
...
} using (ax"extensionalityAxiom", ax"pairAxiom")
show


val oPair =
DEFINE("", x, y) as pair(pair(x, y), pair(x, x))

}
\end{lstlisting}
\caption{Example of library development in LISA Kernel}
\label{fig:kernellibrary}
\end{figure}



Loading

0 comments on commit 49d235f

Please sign in to comment.