Skip to content

Commit

Permalink
Merge pull request #49 from SageMathOER-CCC/boolean
Browse files Browse the repository at this point in the history
Boolean
  • Loading branch information
Samuel-Lubliner authored May 3, 2024
2 parents 732e8fd + 2a9be50 commit 90abbc4
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 3 deletions.
14 changes: 14 additions & 0 deletions source/boolean-algebra/ch-boolean-algebra.ptx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<chapter xml:id="ch-boolean-algebra" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Boolean Algebra</title>

<introduction>
<p> Boolean algebra introduction paragraph here </p>
</introduction>

<!-- include sections -->
<xi:include href="sec-boolean-definition.ptx" />


</chapter>
55 changes: 55 additions & 0 deletions source/boolean-algebra/sec-boolean-definition.ptx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<section xml:id="sec-boolean-definition" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Definition</title>
<p>
Boolean algebra is a branch of algebra that deals with variables that can take two values: true or false. This form of algebra is foundational in fields such as digital electronics and computer science where binary systems are prevalent.
</p>
<p>
In SageMath, Boolean algebra can be manipulated through various built-in functions designed for handling Boolean variables and expressions.
</p>
<sage>
<input>
B = BooleanPolynomialRing(3, 'x')
f = B('x0 + x1 * x2')
show(f)
</input>
<output>
# Outputs the Boolean expression in polynomial form
</output>
</sage>
<p>
A common structure analyzed in Boolean algebra is the lattice. Below, we show how to work with a divisor lattice, which is a specific type of lattice useful in various mathematical computations.
</p>
<sage>
<input>
p = Posets.DivisorLattice(20)
p.show()
</input>
<output>
# This will display the lattice structure for divisors of the number 20.
</output>
</sage>
<p>
The following Sage cell checks whether the divisor lattice is distributive. A distributive lattice is one where the operations of join and meet distribute over each other.
</p>
<sage>
<input>
p = Posets.DivisorLattice(20)
p.is_distributive(certificate='True')
</input>
<output>
# Returns True if the lattice is distributive, along with a certificate if applicable.
</output>
</sage>
<p>
Another important property in Boolean algebra is the complemented lattice. A complemented lattice is one where every element has a complement in the lattice.
</p>
<sage>
<input>
p = Posets.DivisorLattice(20)
p.is_complemented(certificate='True')
</input>
<output>
# Returns True if the lattice is complemented, along with a certificate if applicable.
</output>
</sage>
</section>
9 changes: 6 additions & 3 deletions source/lattices/sec-definition.ptx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<section xml:id="sec-definition" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Definition</title>
<subsection xml:id="definition">
<title>Definition</title>
<p>
A lattice is defined as a partially ordered set (poset) in which any two elements have a least upper bound (also known as join) and greatest lower bound (also known as meet).
</p>
Expand Down Expand Up @@ -44,8 +45,10 @@
<output>
# This will check if the poset is a lattice.
</output>
</sage>

</sage>
</subsection>


<subsection xml:id="join">
<title>Join</title>
<p>
Expand Down
1 change: 1 addition & 0 deletions source/main.ptx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<xi:include href="./graph-theory/ch-graph-theory.ptx" />
<xi:include href="./trees/ch-trees.ptx" />
<xi:include href="./lattices/ch-lattices.ptx" />
<xi:include href="./boolean-algebra/ch-boolean-algebra.ptx" />
<!-- Include backmatter -->
<xi:include href="./backmatter.ptx" />

Expand Down

0 comments on commit 90abbc4

Please sign in to comment.