OpenLLM-France/wikimedia huggingface dataset:
# Linear Algebra over a Ring/Projective and injective modules

Theorem (Baer's criterion):
A module $M$ over a commutative ring $R$ is injective if and only if for every ideal $I\leq R$, every homomorphism $\varphi :I\to M$ of $R$-modules may be extended to a homomorphism of $R$-modules $\Phi :R\to M$, ie. extended to a homomorphism $\Phi :R\to M$ that satisfies $\Phi \upharpoonright _{I}=\varphi$.
Proof: The "only if" part is obvious from the definition of injectivity. Conversely, assume that $M$ satisfies the extension property described in the theorem statement. Let now $K,L$ be $R$-modules, let $\psi :K\to M$ be a homomorphism and let $\iota :K\to L$ be an injection. By the definition of injective modules, we have to prove that there exists a homomorphism $\Psi :L\to M$ that satisfies $\Psi \circ \iota =\psi$, ie. that extends $\psi$ wrt. the inclusion $\iota :K\to L$, as the algebraists say. Now the image $\operatorname {Im} \iota :=L'$ is a submodule of $L$ that is isomorphic to $K$ by the injectivity of $\iota$ via $\iota$, and hence precomposition of the inverse of $\iota$ with $\psi$ yields a homomorphism from $L'$ to $M$. Now we partially order all extensions of this isomorphism by the order that $\alpha \leq \beta$ if and only if
* the domain of $\alpha$ is contained within the domain of $\beta$, and
* $\alpha$ and $\beta$ coincide on the domain of $\alpha$.
By Zorn's lemma, which applies since each chain with respect to this order has an upper bound (namely the function that assigns to an element within the union of the respective domains the value that any of the respective homomorphisms assumes on it), there exists a maximal homomorphism $\Psi$ with respect to that order. We claim that $\Psi$ is defined on all of $L$. Indeed, upon assuming otherwise, we may choose an element $l\in L$ where $\Psi$ is not defined. Let $L''\leq L$ be the domain of definition of $\Psi$, so that $l\notin L''$. Define the ideal
    $I:=\{r\in R|rl\in L''\}$
of $R$; it may be the zero ideal. $\Psi$ is defined on $I$, and yields a homomorphism on $I$. By assumption, this homomorphism may be extended to a homomorphism $f:R\to M$. We then define $L''':=L''+\langle l\rangle$; a submodule of $L$ that is strictly larger than $L''$, since it contains $l$. On $L'''$, we define the homomorphism
    $F(x+sl):=\Psi (x)+sf(l)$ for $x\in L''$ and $s\in R$,
which is a proper extension of $\Psi$, so that $\Psi$ was not maximal, a contradiction. Hence, $\Psi$ was defined on all of $L$ from the beginning and yields the desired extension of $\psi$. $\Box$
# Linear Algebra with Differential Equations

As the title suggests, we assume you have prior knowledge of differential equations and linear algebra separately.
The book is structured into three main chapters, each with an important introduction that itself introduces material (So don't just skim over it thinking it's part of an outline) and then leads into method-heavy subsections. Other than that, enjoy!

## Contents
### Homogeneous Linear Differential Equations

* Real, Distinct Eigenvalues Method
* Imaginary Eigenvalues Method
* Repeated Eigenvalue Method

### Heterogeneous Linear Differential Equations

* Diagonalization
* Method of Undetermined Coefficients
* Variations of Parameters
* Laplacian Transforms
# Linear Algebra over a Ring/Homomorphism and dual modules

Proposition (multiple of module homomorphism by a ring element over a commutative ring is module homomorphism):
Let $M,N$ be modules over the commutative ring $R$. Let $\phi :M\to N$ be a homomorphism of $R$-modules, and let $r\in R$. Then the function
    $rf:M\to N,(rf)(m):=rf(m)$
is an $R$-module morphism too.
Proof: Let $s\in R$ and $m,n\in M$. Then $(rf)(m+n)=(rf)(m)+(rf)(n)$ and since $R$ is commutative, also $(rf)(sm)=rsf(m)=s(rf)(m)$. $\Box$
Definition (homomorphism module):
Let $R$ be a commutative ring
Definition (dual):
Let $R$ be a commutative ring, and let $M$ be an $R$-module. Then $\operatorname {Hom} _{R}(M,R)$ has a module structure given by addition and pointwise multipliction (since the category of modules over a ring is additive and the addition that is implied is compatible with pointwise multiplication, under which $\operatorname {Hom} _{R}(M,R)$ is closed), and this module, denoted more briefly by $M^{*}$, is called the dual of $M$.
Proposition (the category of modules is abelian):
Let $R$ be a ring. Then the category $R-{\textbf {Mod}}$ of left $R$-modules is abelian. Also, the category ${\textbf {Mod}}-R$ of right $R$-modules is abelian.
Proof: Existence of kernels and cokernels has been dealt with, and the same holds for existence of binary biproducts, since then product and sum coincide in this category. Also, the Noether isomorphism theorem holds. Then, the category is additive. Indeed, the summation on the homomorphism group indicated above is precisely the addition in the categorical sense. $\Box$
# Linear Algebra over a Ring/Modules over principal ideal domains

Proposition (torsion-free modules over principal ideal domains are free):
Let $R$ be a principal ideal domain, and let $M$ be a torsion-free module over $R$. Then $M$ is free.
Proof: We consider the set of sets $S\subseteq M$ such that $S$ is linearly independent and $M/\langle S\rangle$ is torsion-free. This set may be equipped with the partial order that is given by inclusion. Suppose then that $A$ is a totally ordered set, and $(S_{\alpha })_{\alpha \in A}$ is a family such that $\alpha \leq \beta \Leftrightarrow S_{\alpha }\subseteq S_{\beta }$. We claim that an upper bound for this chain is given by the union of the sets $S_{\alpha }$, which we shall denote by $S_{\infty }$. Indeed, $S_{\infty }$ is linearly independent, since any linear relation within $S_{\infty }$ involves only finitely many elements of $S_{\infty }$, and we may find a sufficiently large (w.r.t. the order of $A$) $\alpha \in A$ such that all these elements are contained within $S_{\alpha }$, so that by the linear independence of $S_{\alpha }$ the given linear relation must be trivial. Moreover, $S_{\infty }$ has the property that $M/\langle S_{\infty }\rangle$ is torsion-free, since if $m\in M$ and $r\in R$ are given such that $m\notin S_{\infty }$, but $rm\in S_{\infty }$ (ie. the equivalence class of $m$ in $M/\langle S_{\infty }\rangle$ is torsion), then $rm$ is a linear combination of finitely many elements of $S_{\infty }$, so that once more we find a sufficiently large $\alpha \in A$ such that $rm\in S_{\alpha }$, and then the equivalence class of $m$ in $R/\langle S_{\alpha }\rangle$ is torsion, a contradiction.
Thus, Zorn's lemma may be applied, and it yields a maximal linearly independent $S\subseteq M$ such that $M/\langle S\rangle$ is torsion-free. We lead the assumption $\langle S\rangle \neq M$ to a contradiction. Indeed, if we had $\langle S\rangle \neq M$, then there would be an element $m\in M\setminus \langle S\rangle$. The set $S\cup \{m\}$ will then be linearly independent, for if there was a linear relation
    $0=rm+r_{1}s_{1}+\cdots +r_{n}s_{n}$ (where $r,r_{1},\ldots ,r_{n}\in R$ and $s_{1},\ldots ,s_{n}\in S$),
then we would have $(-r)m=r_{1}s_{1}+\cdots +r_{n}s_{n}\in \langle S\rangle$ and the equivalence class of $m$ in $M/\langle S\rangle$ would be torsion. $\Box$
Theorem (Dedekind's theorem):
Let $R$ be a principal ideal domain. Whenever $M$ is a free $R$-module and $N\leq M$ is a submodule, $N$ is free as well.
Proof: Since $N$ is a submodule of a torsion-free module, it is itself torsion-free. Thus, the theorem holds, since torsion-free modules over principal ideal domains are free. $\Box$
# Linear Algebra over a Ring/Modules and linear functions

Definition (module):
Let $R$ be a ring. A left $R$-module is an abelian group $(M,+)$ together with a function $R\times M\to M$, denoted by juxtaposition, that satisfies the following axioms for all $r,s\in R$ and $m,n\in M$:
* $1m=m$
* $(r+s)m=rm+sm$
* $r(sm)=(rs)m$
* $r(m+n)=rm+rn$
Definition (homogenous):
Let $M$, $N$ be left modules over a ring $R$. A function $f:M\to N$ is called homogenous if and only if for all $r\in R$ and $m\in N$ the identity
    $f(rm)=rf(m)$
holds.
Definition (linear):
Let $M$, $N$ be left modules over a ring $R$. A function $f:M\to N$ is called linear if and only if it is both homogenous and a morphism of abelian groups from $M$ to $N$.
Theorem (first isomorphism theorem):
Let $M$ and $N$ be left modules over a ring $R$. Let $\varphi :M\to N$ be linear. Then
    $M/\ker \varphi \cong \operatorname {im} \varphi$.
Proof: $\Box$

## Exercises

* Prove that for a function $f:M\to N$ between left $R$-modules, the following are equivalent:
** $f$ is linear
** For all $m,n\in M$ and $r\in R$, we have $f(m+n)=f(m)+f(n)$ and $f(rm)=rf(m)$
** For all $m,n\in M$ and $r\in R$, we have $f(m+rn)=f(m)+rf(n)$
** For all $m,n\in M$ and $r,s\in R$, we have $f(rm+sn)=rf(m)+sf(n)$
# Programming Fundamentals/Object Examples CSharp
## References

* Wikiversity: Computer Programming
# Programming Fundamentals/Object Examples Python
## References

* Wikiversity: Computer Programming
# Programming Fundamentals/Nothing Data Type
## Overview

A nothing data type is a feature of some programming languages which allow the setting of a special value to indicate a missing or uninitialized value rather than using the value 0 (zero).

## Discussion

Most programming languages support the use of a reserved word or words to represent missing, uninitialized, or invalid values.
| Language | Reserved Word | Meaning |
| C++ | null | no value |
| C# | null | no value |
| Java | null | no value |
| JavaScript | null | no value |
| JavaScript | NaN | Not a Number |
| Python | None | no value |
| Swift | nil | no value |

## Key Terms
### NaN

    Reserved word used to indicate a non-numeric value in a numeric variable.

### Null

    Reserved word used to represent a missing value or invalid value.

## References

* ↑ Wikipedia: Nullable type
# Programming Fundamentals/Object Examples C++
## References

* Wikiversity: Computer Programming
# Programming Fundamentals/Object Examples Swift
## References

* Wikiversity: Computer Programming
# Programming Fundamentals/Nested If Then Else
## Overview

Two-way selection structures may be nested inside other two-way selection structures, resulting in multi-way selection.

## Discussion

We are going to first introduce the concept of nested control structures. Nesting is a concept that places one item inside of another. Consider:
This is the basic form of the if then else control structure. Now consider:
As you can see we simply included as part of the “true action” a statement and another if then else control structure. We did the same (nested another if then else) for the “false action”. In our example, we nested if then else control structures. Nesting could have an if then else within a while loop. Thus, the concept of nesting allows the mixing of the different categories of control structures.

### Multiway Selection

One of the drawbacks of two-way selection is that we can only consider two choices. But what do you do if you have more than two choices? Consider the following which has four choices:
You get an appropriate message depending on the value of age. The last item is referred to as the default. If the age is not equal to 18, 39 or 65 you get the default message. To simplify the code structure, this is most often written as:

## Key Terms
### multiway selection

    Using control structures to be able to select from more than two choices.

### nested control structures

    Placing one control structure inside of another.

## References

* cnx.org: Programming Fundamentals – A Modular Structured Approach using C++
# Programming Fundamentals/Nested Loops
## Overview

Nested for loops places one for loop inside another for loop. The inner loop is repeated for each iteration of the outer loop.

## Discussion
#### Nested Control Structures

We are going to first introduce the concept of nested control structures. Nesting is a concept that places one item inside of another. Consider:
This is the basic form of the if then else control structure. Now consider:
As you can see we simply included as part of the “true action” a statement and another if then else control structure. We did the same (nested another if then else) for the “false action”. In our example, we nested if then else control structures. Nesting could have an if then else within a while loop. Thus, the concept of nesting allows the mixing of the different categories of control structures.
Many complex logic problems require using nested control structures. By nesting control structures (or placing one inside another) we can accomplish almost any complex logic problem.

### An Example – Nested for loops

Here is an example of a 10 by 10 multiplication table:
We might also see that the answers could be designed as a collection of cells (each cell being exactly six spaces wide). The pseudocode to produce part of the table is:

### An Example - Nested Do While For Loops

Please input what number you want to multiply 3 What number do you want constant 2 2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 Would you like another set? Type yes no Ok bye
Here is a pseudo code for the example above

## Key Terms
### complex logic

    Often solved with nested control structures.

## References

* cnx.org: Programming Fundamentals – A Modular Structured Approach using C++
# Programming Fundamentals/Object Examples JavaScript
## References

* Wikiversity: Computer Programming
# Programming Fundamentals/Object-Oriented Programming
## Overview

This chapter introduces object-oriented programming, with a focus on understanding object-oriented concepts and terminology. It includes short examples of objects and classes in different programming languages.

## Chapter Outline

* Objects and Classes
* Encapsulation
* Inheritance and Polymorphism
* Code Examples
** C++
** C#
** Java
** JavaScript
** Python
** Swift
* Practice: Object-Oriented Programming

## Learning Objectives

* Understand key terms and definitions.
* Gain exposure to object-oriented programming.
* Given example source code, create a program that uses object-oriented programming concepts to solve a given problem.
# Programming Fundamentals/Object Examples Java
## References

* Wikiversity: Computer Programming
# Programming Fundamentals/Branching Statements
## Overview

A branch is an instruction in a computer program that can cause a computer to begin executing a different instruction sequence and thus deviate from its default behavior of executing instructions in order. Common branching statements include break, continue, return, and goto.

## Discussion

Branching statements allow the flow of execution to jump to a different part of the program. The common branching statements used within other control structures include: break, continue, return, and goto. The goto is rarely used in modular structured programming. Additionally, we will add to our list of branching items a pre-defined function commonly used in programming languages of: exit.

### Examples
#### break

Break terminates the existing structure. Break is used in one of two ways; with a switch to make it act like a case structure or as part of a looping process to break out of the loop. The following gives the appearance that the loop will execute 8 times, but the break statement causes it to stop during the fifth iteration.

#### continue

Continue causes the loop to stop its current iteration and begin the next one. The following gives the appearance that the loop will print to the monitor 8 times, but the continue statement causes it not to print number 4.

#### return

Return causes the function to jump back to the function that called it. The return statement exits a function and returns to the statement where the function was called.

#### goto

Goto causes logic to jump to a different place. The goto structure is typically not accepted in good structured programming. However, some programming languages allow you to create a label with an identifier name followed by a colon. You use the command word goto followed by the label.

#### exit

Exit is a pre-defined function which prematurely stops the execution of the program and causes it to jump to another place in the program. A good example is the opening a file and then testing to see if the file was actually opened. If not, we have an error that usually indicates that we want to prematurely stop the execution of the program. The exit function terminates the running of the program and in the process returns an integer value back to the operating system.

## Key Terms
### branching statements

    Allow the flow of execution to jump to a different part of the program.

### break

    A branching statement that terminates the existing structure.

### continue

    A branching statement that causes a loop to stop its current iteration and begin the next one.

### exit

    A predefined function used to prematurely stop a program and return to the operating system.

### goto

    An unstructured branching statement that causes the logic to jump to a different place in the program.

### return

    A branching statement that causes a function to jump back to the function that called it.

## References

* cnx.org: Programming Fundamentals – A Modular Structured Approach using C++
* ↑ Wikipedia: Branch (computer science)
# Programming Fundamentals/Author Acknowledgements
## 1st Edition Acknowledgements

I wish to acknowledge the many people who have helped me and have encouraged me in this project.
* Mr. Abass Alamnehe, who is a fellow faculty member at Houston Community College. He has encouraged the use of Connexions as an “open source” publishing concept. His comments on several modules have led directly to the improvement of the materials in this textbook/collection.
* The hundreds (most likely a thousand plus) students that I have taken programming courses that I have taught since 1984. The languages include: COBOL, mainframe IBM assembly, Intel assembly, Pascal, “C” and “C++”. They have often suggested that I write my own book because they thought that I was explaining the subject matter better than the author of the textbook that we were using. Little did my students understand that directly or indirectly they aided in the improvement of the materials from which I taught as well as improving me as a teacher.
* To my future students and all those that will use this textbook/collection. They will provide suggestions for improvement as well as being the thousand eyes identifying the hard to find typos, etc.
* My wife, Carol, who supports me in all that I do. She has tolerated the many hours that I have spent in concentration on developing the modules that comprise this work. Without her support, this work would not have happened.
Kenneth Leroy Busbee

## 2nd Edition Acknowledgements

I wish to acknowledge the many people who have helped make this edition possible, including:
* Kenneth Leroy Busbee for his initial vision and willingness to share Programming Fundamentals – A Modular Structured Approach using C++ as CC-BY, making it possible to build on his success.
* University of Cape Town for likewise sharing Object-Oriented Programming in Pythonas CC-BY-SA and making it possible to build on their efforts.
* Jay Singelmann and Jean Longhurst, who first taught me structured programming.
* Joyce Farrell, whose Programming Logic and Design book I have used for several years and has no doubt influenced my approach.
* Devin Cook for developing Flowgorithm, releasing it as free software, and graciously allowing its use to generate most of the pseudocode and flowcharts used in this edition of the book.
* Zoe Wake Hyde and the staff and volunteers at Rebus Community for providing a community and platform to create and collaborate on open content.
* April Browne, Carol Potaczek, and Maisie Sparks for providing subject matter expertise and recommendations for content improvement.
* My wife and family for accepting my dedication to open educational resources and loving me anyway.
Dave Braunschweig

## References

* cnx.org: Programming Fundamentals – A Modular Structured Approach using C++
* Cover Art: Puzzle pieces – CC0 by MsReadIt, downloaded from https://openclipart.org/detail/231093/puzzle-pieces
# Programming Fundamentals/Code Blocks
## Overview

A code block, sometimes referred to as a compound statement, is a lexical structure of source code which is grouped together. Blocks consist of one or more declarations and statements. A programming language that permits the creation of blocks, including blocks nested within other blocks, is called a block-structured programming language. Blocks are fundamental to structured programming, where control structures are formed from blocks.

## Discussion
### The Need for a Compound Statement

Within many programming languages, there can be only one statement listed as the action part of a control structure:
Often, we will want to do more than one statement. This problem is overcome by creating a code block or compound statement. For programming languages that use curly braces to designate code blocks, a compound if-then-else statement would be similar to:
Because programmers often forget that they can have only one statement listed as the action part of a control structure; the programming industry encourages the use of indentation (to see the action parts clearly) and the use of compound statements (braces) always, even when there is only one statement. Thus:
By writing code in this manner, if the programmer modifies the code by adding more statements to either the action true or the action false; they will not introduce either compiler or logic errors. Using indentation and braces should become standard practice in any language that requires the use of compound statements with control structures.

### Indentation and End Block

Other programming languages require explicit designation of code blocks through either indentation or some type of end block statement. For example, Python uses indentation to indicate the statements in a code block:
Lua uses an end block reserved word:
The general if-then-else structure in each of these programming languages is similar, as is the required or expected indentation. The difference is in the syntax used to designate the code blocks.

## Key Terms
### block

    Another name for a compound statement.

### compound statement

    A unit of code consisting of one or more statements.

## References

* cnx.org: Programming Fundamentals – A Modular Structured Approach using C++
* ↑ Wikipedia: Block (programming)