AllRounder.ai
Chapters in this course

Enrol to start learning

Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.

Enrol free

3.2.2. Encoding Sudoku with Propositional Variables

Interactive Audio Lesson

Session 1: Introduction to the SAT Problem

Unlock the classroom podcast

The transcript is free to read. A free account plays the conversation back.

Sarah
SarahInstructor

Today, we are talking about the SAT problem or the satisfiability problem. Can anyone tell me what that might involve?

Noah
Noah

Is it about finding if a logical statement can ever be true?

Sarah
SarahInstructor

Exactly, great observation! A proposition is called satisfiable if there exists at least one truth assignment making it true. For example, in the expression X involving variables p, q, and r, if we make p, q, and r all true, X becomes true. Remember, even one true assignment suffices to categorize X as satisfiable.

Isabella
Isabella

What if it’s not satisfiable?

Sarah
SarahInstructor

Good question! If there’s no truth assignment that can make X true, it's unsatisfiable. We can define unsatisfiable as the negation of X being a tautology.

Akash
Akash

What’s a tautology again?

Sarah
SarahInstructor

A tautology is always true, regardless of the truth assignments of its propositional variables. This is key when we assess whether a compound statement is satisfiable or not.

Sarah
SarahInstructor

To summarize, the SAT problem checks if there’s at least one way to assign truth values that makes the proposition true.

Session 2: Understanding Conjunctive Normal Form (CNF)

Unlock the classroom podcast

The transcript is free to read. A free account plays the conversation back.

Robert
RobertInstructor

Now, let’s move on to Conjunctive Normal Form, often called CNF. Who can describe what CNF entails?

Ananya
Ananya

Is it like a special way of writing logical statements?

Robert
RobertInstructor

Exactly! A formula is in CNF if it’s expressed as a conjunction of one or more clauses. Each clause is composed of literals that can be either a variable or its negation.

Noah
Noah

Can you give an example of a CNF expression?

Robert
RobertInstructor

"Certainly! The expression

Session 3: Application: Sudoku Problem and its Encoding

Unlock the classroom podcast

The transcript is free to read. A free account plays the conversation back.

Sarah
SarahInstructor

Now let's apply these ideas to something fun: Sudoku puzzles! How can we use propositional variables to represent a Sudoku challenge?

Isabella
Isabella

We can create propositions that say a number is in a particular cell?

Sarah
SarahInstructor

Exactly! For instance, we can define p(i, j, n) as a proposition meaning 'number n is in cell (i, j)'.

Ananya
Ananya

What do we do with the already filled cells?

Sarah
SarahInstructor

Great catch! If a cell is filled with a number, we set that propositional variable to true. For example, if cell (5, 1) has the number 6, then p(5, 1, 6) is true.

Akash
Akash

What if I want numbers in a row or column?

Sarah
SarahInstructor

We will encode the requirements! Each row must contain numbers 1-9 exactly once. We represent this as a set of disjunctions over the columns for each row. For instance, to say the number 1 appears in row i could be represented by the disjunction of p(i, 1, 1), p(i, 2, 1), up to p(i, 9, 1).

Sarah
SarahInstructor

So, the task boils down to framing these rules into propositional logic and checking if a satisfying assignment exists for all constraints!