Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro to include executable lisa listings from a file #230

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions refman/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ lisa.fls
lisa.log
lisa.out
lisa.toc
src/.scala-build
Binary file modified refman/lisa.pdf
Binary file not shown.
3 changes: 2 additions & 1 deletion refman/lisa.tex
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
\date{}

% PDF links and meta data
\usepackage{hyperref}
%\usepackage{hyperref}
\usepackage{bookmark}
\makeatletter
\hypersetup{
colorlinks=true,
Expand Down
3 changes: 3 additions & 0 deletions refman/macro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,6 @@

\DeclareMathOperator{\pick}{pick}

\newcommand{\lisaCode}[3]{
\lstinputlisting[language=lisa, frame=single,caption=\href{#1}{#2}, #3]{#1}
}
29 changes: 1 addition & 28 deletions refman/prooflib.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,7 @@ \chapter{Developping Mathematics with Prooflib}
\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 {
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}
\caption{An example of a theory file in Lisa}
\lisaCode{src/MyTheoryName.scala}{An example of a theory file in Lisa}{firstline=3}
\label{fig:theoryFileExample}
\end{figure}

Expand Down
29 changes: 29 additions & 0 deletions refman/src/MyTheoryName.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//> using scala 3.5.1
//> using jar "../../../lisa/target/scala-3.5.1/lisa-assembly-0.7.jar"
object MyTheoryName extends lisa.Main:
val x = variable
val y = 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)
}

@main def show = println(emptySetAxiom)