diff --git a/.devcontainer.json b/.devcontainer.json
index 7c4ad3ec..9fb95e39 100644
--- a/.devcontainer.json
+++ b/.devcontainer.json
@@ -1,12 +1,3 @@
-//////////////////////////////////////////////////////////////
-//
-// This file provides configuration options so that a PreTeXt
-// project can be edited and built using GitHub's Codespaces.
-// It is recommended to keep this in your repository even if you
-// do not use this feature, as it will allow other to explore
-// your project easily.
-//
-///////////////////////////////////////////////////////////////
{
"name": "PreTeXt-Codespaces",
diff --git a/.github/workflows/pretext-cli.yml b/.github/workflows/pretext-cli.yml
index 3c73b5c8..c7b2ba08 100644
--- a/.github/workflows/pretext-cli.yml
+++ b/.github/workflows/pretext-cli.yml
@@ -3,11 +3,9 @@ on:
# Runs on pull requests
pull_request:
branches: ["*"]
-
# Runs on pushes to main
push:
branches: ["main"]
-
# Runs on demand
workflow_dispatch:
@@ -15,44 +13,17 @@ jobs:
build:
runs-on: ubuntu-latest
container: oscarlevin/pretext:full
+
steps:
- name: Checkout source
uses: actions/checkout@v4
- - name: Set up Python
- uses: actions/setup-python@v4
- with:
- python-version: '3.x'
-
- - name: Install dependencies
- run: |
- apt-get update
- apt-get install -y inkscape
- shell: bash
-
- - name: Verify Inkscape Installation
- run: inkscape --version
-
- name: install deps
- run: |
- pip install -r requirements.txt
- pretext --version
-
- - name: ensure proper asset type in image references
- run: ./update-img-refs.py source/ --to-svg
+ run: pip install -r requirements.txt
- name: build deploy targets
- run: |
- version="$(pretext --version)"
- major="$(echo $version | cut -d '.' -f 1)"
- minor="$(echo $version | cut -d '.' -f 2)"
- if [ "$major" -ge 2 -a "$minor" -ge 5 ]; then
- echo "PreTeXt version is 2.5 or greater; using new build command"
- pretext build --deploys
- else
- echo "PreTeXt version is less than 2.5, using old build command"
- pretext build
- fi
+ run: pretext build --deploys
+
- name: stage deployment
run: pretext deploy --stage-only
@@ -62,11 +33,6 @@ jobs:
name: deploy
path: output/stage
- - name: ensure proper asset type in image references for pdf output
- run: |
- make svg-to-pdf
- ./update-img-refs.py source/ --to-pdf
-
- name: Build PDF with PreTeXt
run: pretext build print
@@ -140,7 +106,7 @@ jobs:
- name: Commit changes
run: |
- git add output/print/discrete-math-with-sage.pdf
+ git add output/print/main.pdf
git commit -m "Update PDF" || echo "No changes to commit"
- name: Force push to pdf-update branch
diff --git a/.gitignore b/.gitignore
index eaad9e29..2cd75baa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,10 +2,9 @@
# ensure this file is tracked
!.gitignore
-# don't track unpublished builds or stage (note: Runestone uses `published`)
+# don't track unpublished builds or stage
output/web
output/stage
-published
# don't track assets generated from source
generated-assets
@@ -99,16 +98,3 @@ codechat_config.yaml
# Don't track local files under /venv (virtual local environment)
venv
-
-# Don't track local temp files and generated files
-*.local
-*.bak
-*.swp
-*.old
-*.log
-*.tmp
-assets/*/*.pdf
-
-# Don't track deprecated workflows
-.github/workflows/deploy.yml
-.github/workflows/test-build.yml
diff --git a/Makefile b/Makefile
deleted file mode 100644
index b896d141..00000000
--- a/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
-# Define the directory containing the SVG files
-SVG_DIR := assets
-
-# Find all SVG files recursively in the assets directory
-SVG_FILES := $(shell find $(SVG_DIR) -type f -name '*.svg')
-
-# Create a list of PDF files by replacing the .svg extension with .pdf
-PDF_FILES := $(SVG_FILES:.svg=.pdf)
-
-# Check if Inkscape is available and print its version
-INKSCAPE := $(shell command -v inkscape)
-ifeq ($(INKSCAPE),)
-$(error "Inkscape is required but is not installed or not on the PATH.")
-else
-INKSCAPE_VERSION := $(shell inkscape --version)
-endif
-
-## svg-to-pdf: Run the full pipeline: check inkscape, clean generated PDFs, and convert SVGs to PDFs
-svg-to-pdf: check-inkscape clean convert
-
-# Verify Inkscape installation and display its version
-check-inkscape:
- @echo "Using Inkscape: $(INKSCAPE_VERSION)"
-
-# Remove all generated PDF files in the assets directory
-clean:
- @echo "Cleaning up generated PDF files..."
- find $(SVG_DIR) -type f -name '*.pdf' -exec rm -f {} +
- @echo "Cleanup complete."
-
-# Convert all SVG files in the assets directory to PDFs
-convert: $(PDF_FILES)
-
-# Pattern rule to convert a single SVG to a PDF
-%.pdf: %.svg
- @echo "Converting $< to $@..."
- $(INKSCAPE) -o $@ $<
-
-## help: Display this help message
-help:
- @echo "Makefile for converting SVG files to PDF using Inkscape"
- @echo
- @echo "Available targets:"
- @awk '/^##/ {print substr($$0, 4)}' $(MAKEFILE_LIST) | sort
diff --git a/assets/finite-state-machines/first_traffic_light_FSM.png b/assets/finite-state-machines/first_traffic_light_FSM.png
new file mode 100644
index 00000000..43d7d0c0
Binary files /dev/null and b/assets/finite-state-machines/first_traffic_light_FSM.png differ
diff --git a/assets/finite-state-machines/first_traffic_light_FSM.svg b/assets/finite-state-machines/first_traffic_light_FSM.svg
deleted file mode 100644
index 9cda8ba2..00000000
--- a/assets/finite-state-machines/first_traffic_light_FSM.svg
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
diff --git a/assets/finite-state-machines/intersection_2_ways.png b/assets/finite-state-machines/intersection_2_ways.png
new file mode 100644
index 00000000..48f9a1c2
Binary files /dev/null and b/assets/finite-state-machines/intersection_2_ways.png differ
diff --git a/assets/finite-state-machines/intersection_4_ways.png b/assets/finite-state-machines/intersection_4_ways.png
new file mode 100644
index 00000000..055c0e5d
Binary files /dev/null and b/assets/finite-state-machines/intersection_4_ways.png differ
diff --git a/assets/finite-state-machines/simple_traffic_light.png b/assets/finite-state-machines/simple_traffic_light.png
new file mode 100644
index 00000000..1c2e4a76
Binary files /dev/null and b/assets/finite-state-machines/simple_traffic_light.png differ
diff --git a/assets/finite-state-machines/simple_traffic_light.svg b/assets/finite-state-machines/simple_traffic_light.svg
deleted file mode 100644
index b274affc..00000000
--- a/assets/finite-state-machines/simple_traffic_light.svg
+++ /dev/null
@@ -1,157 +0,0 @@
-
-
diff --git a/project.ptx b/project.ptx
index 2489cc80..10faf1f6 100644
--- a/project.ptx
+++ b/project.ptx
@@ -1,22 +1,8 @@
-
+
The factorial of a non-negative integer
Compute the factorial of
+ The factorial of a non-negative integer
+ Compute the factorial of
The combination
+ The combination
Calculate the number of ways to choose
+ Calculate the number of ways to choose
List the combinations:
@@ -46,40 +46,39 @@
Combinations(5, 3).list()
+
-
The
+ The
A permutation
+ A permutation
To calculate the number of ways to choose
+ To calculate the number of ways to choose
List the permutations: @@ -88,13 +87,19 @@ Permutations(5, 3).list() + -
When
Calculate the number of permutations of a set with
+ When
+ Calculate the number of permutations of a set with
List the permutations: @@ -103,6 +108,7 @@ Permutations(3).list() +
The following is an example of permutations of specified elements: @@ -113,14 +119,18 @@ A.list() + -
Choose
+ Choose
Although Sage includes a dedicated built-in rich module to handle various types of - state machines, it may not always be sufficient to address certain use cases or - implement specific custom behaviors of the machine. Additionally, the built-in module allows state + state machines, it may not always be sufficient to address certain use cases or implement + specific custom behaviors of the machine. Additionally, the built-in module allows state machines to be defined and constructed in different ways, providing greater flexibility and making it more suitable from a programmer's perspective. However, it may not fully - conform to the precise definition given earlier. This highlights that it is still - possible to model, construct, display, and run relatively simple state machines by utilizing + conform to the precise definition given earlier. This highlights that it is still possible + to model, construct, display, and run relatively simple state machines by utilizing general-purpose tools, such as graphs and transition matrices, to represent and operate on state machines.
-- Let's design a basic controller to an elevator to show the process of defining states, - creating a state transition graph, visualizing the state machine, and simulating its execution in - Sage.
+ Let's design a basic controller to an elevator to show the process of defining states, creating + a state transition graph, visualizing the state machine, and simulating its execution in Sage.- Consider a 3-level elevator (floors 1 through 3). The elevator can be at one of the - three floors and moves in the same direction (up or down) until it reaches the top or bottom floor. - It stops at each floor along the way. The elevator has 3 buttons for users to select the - destination floor (only one can be selected at a time). Depending on the current position and the selected - floor, the elevator can go up, go down, or remain on the same floor.
- - This elevator system can be modeled and simulated using a finite-state machine with
- states
- The components of this FSM are transcribed in the following table.
--
The following steps outline the approach to build and test the elevator controller system: -
Define the elements of the Finite State Machine: States, Inputs, Transitions, and Outputs.
-Construct the State Machine.
-Run the machine using a sample input set.
-- The first step is to define the states and transitions in the state machine, - which can be represented using lists and dictionaries.
-- An FSM can be modeled as a graph where vertices represent the states, and the directed - edge between vertices is the relationship between two states (the transition from - one state to the other). The weight of a directed edge between two vertices represents - the pair of input and output associated with the transition between the two states.
- - In Sage, the
The
- Next, the state machine's behavior can be simulated by defining a function that - processes a list of inputs and transitions through the states accordingly.
- The
+ This elevator system can be modeled and simulated using a finite-state machine with
+ states
+ The components of this FSM are transcribed in the following table.
++
+ The following steps outline the approach to build and test the elevator controller system: +
Define the elements of the Finite State Machine: States, Inputs, Transitions, and Outputs.
+Construct the State Machine.
+Run the machine using a sample input set.
++ The first step is to define the states and transitions in the state machine, + which can be represented using lists and dictionaries.
++ An FSM can be modeled as a graph where vertices represent the states, and the directed + edge between vertices is the relationship between two states (the transition from one + state to the other). The weight of a directed edge between two vertices represents the + pair of input and output associated with the transition between the two states.
+ + In Sage, the
The
+ Next, the state machine's behavior can be simulated by defining a function that + processes a list of inputs and transitions through the states accordingly.
+ The
Consider a simplified traffic light system controlled by preset timers. This system +
+ Consider a simplified traffic light system controlled by preset timers. This system
operates through three phases that represent the flow of road traffic: Free-flowing,
Slowing-down, and Halted. These phases correspond to the traffic light signals: green,
yellow, and red, controlling the flow of traffic. The system uses three timer settings:
-
- When the
- When the
- When the
In this traffic light system, the three phases representing the flow of road
- traffic: Free-flowing (F), Slowing-down (S), and Halted (H)
- are the states
+ In this traffic light system, the three phases representing the flow of road traffic: Free-flowing (F), Slowing-down (S),
+ and Halted (H) are the states
The following table summarize the elements of the traffic light FSM.
@@ -365,147 +311,96 @@
- By applying the same steps and approach as in the previous section, the traffic light - controller system will be built and tested, this time utilizing the Sage built-in module and functions.
+ By applying the same steps and approach as in the previous section, the traffic light controller + system will be built and tested, this time utilizing the Sage built-in module and functions. Sage
The command
+ Sage
+ The command
The function
+ The function
To check whether or not a finite state machine has a state defined,
The function
+ The function
The method
+ The method
To define a new transition between two states (as well as the input triggering the
- transition, and the output associated with the state transition), the method
-
+ To define a new transition between two states (as well as the input triggering the transition, and
+ the output associated with the state transition), the method
An alternative method for defining state transitions in an FSM is by using the
-
+ An alternative method for defining state transitions in an FSM is by using the
Once the states and transitions are defined, the state machine can be run using
-
The
+ The
The
The
Note that the
+ Note that the
Sage
+ Sage
Let's see how to create another state machine using
+ Let's see how to create another state machine using
The member variable
+ The member variable
The member variable
+ The member variable
Since a
Since a
The function
+ The function
The method
+ The method
After defining the states and transitions, the transducer can be executed using the
-
+ After defining the states and transitions, the transducer can be executed using the
The
+ The
- The above are basic commands with a typical workflow of defining and running of simple - finite state machines. The general structure of the state machine can be adapted to fit - different use cases. The examples shown can be customized and fine-tuned to reflect more - complex scenarios (more states, different input sequences, etc.)
+ The above are basic commands with a typical workflow of defining and running of simple finite + state machines. The general structure of the state machine can be adapted to fit different use + cases. The examples shown can be customized and fine-tuned to reflect more complex scenarios + (more states, different input sequences, etc.)
A function from a set
+ A function from a set
In Sage, functions can be defined using direct definition.
- For example, defining a function
+ For example, defining a function
- Sage provides powerful tools for visualizing functions, enabling you to explore the - graphical representations of mathematical relationships. + Sage provides powerful tools for visualizing functions, enabling you to explore the graphical representations of mathematical relationships. +
+
+ For example, to plot the function
For example, to plot the function
- Recursion is a method where the solution to a problem depends on solutions to smaller - instances of the same problem. This approach is extensively used in mathematics and - computer science, especially in the computation of binomial coefficients, the evaluation - of polynomials, and the generation of sequences. + Recursion is a method where the solution to a problem depends on solutions to smaller instances of the same problem. This approach is extensively used in mathematics and computer science, especially in the computation of binomial coefficients, the evaluation of polynomials, and the generation of sequences.
- A recursive sequence is defined by one or more base cases and a recursive step that - relates each term to its predecessors. + A recursive sequence is defined by one or more base cases and a recursive step that relates each term to its predecessors.
- Given a sequence defined by a recursive formula, we can ask Sage to find its closed
- form. Here,
+ Given a sequence defined by a recursive formula, we can ask Sage to find its closed form. Here,
We can use the
Similarly, the Fibonacci sequence is another example of a recursive sequence, defined by
- the base cases
+ We can use the
+ Similarly, the Fibonacci sequence is another example of a recursive sequence, defined by the base cases
The
We can also write a function
+ The
+ We can also write a function
We go back to the previous method where we calculated the closed form
+ We go back to the previous method where we calculated the closed form
As we can see, we obtain the same number either by evaluating the closed form at
+ As we can see, we obtain the same number either by evaluating the closed form at
Binomial coefficients, denoted as
+ Binomial coefficients, denoted as
- We can also explore the recursive nature of binomial coefficients by defining a function - ourselves recursively. + We can also explore the recursive nature of binomial coefficients by defining a function ourselves recursively.
This function implements the recursive formula
+ This function implements the recursive formula
The
An alternative way to display the table with better separation and visuals would be to use
-
- The command
Expanding on the concept of truth tables, we can analyze logical expressions involving three
- variables. This provides a deeper understanding of the interplay between multiple
- conditions. The