2022-12-17 15:30:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								categories:
							 
						 
					
						
							
								
									
										
										
										
											2022-12-18 13:00:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  -  Logic
							 
						 
					
						
							
								
									
										
										
										
											2022-12-19 07:00:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  -  Computer Architecture
							 
						 
					
						
							
								
									
										
										
										
											2022-12-19 07:30:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								tags: [logic, propositional-logic, nand-to-tetris]
							 
						 
					
						
							
								
									
										
										
										
											2022-12-17 15:30:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Boolean functions
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								An example of a Boolean function:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$$
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								f(x,y,z) = (x \land y) \lor (\lnot(x) \land z )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$$
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Here is a work through where $f(1, 0, 1)$:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-27 16:30:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								-  The first disjunction : $\lnot(x) \land z$ is false because $x$ is 1 and $z$ is 0
							 
						 
					
						
							
								
									
										
										
										
											2022-12-18 13:00:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								-  The second disjunction: $x \land y$ is false because $x$ is 1 and $y$ is 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-  The overall function returns false because the main connective is disjunction and both of its disjuncts are false
							 
						 
					
						
							
								
									
										
										
										
											2022-12-17 15:30:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 07:30:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								We can compute all possible outputs of the function by constructing a [truth table ](/Logic/Propositional_logic/Truth-tables.md ) with each possible variable as the truth conditions and the output of the function as the truth value:
							 
						 
					
						
							
								
									
										
										
										
											2022-12-17 16:30:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| $x$ | $y$ | $z$ | $f(x,y,z) = (x \land y) \lor (\lnot(x) \land z )$ |
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| --- | --- | --- | ------------------------------------------------- |
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| 0   | 0   | 0   | 0                                                 |
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| 0   | 0   | 1   | 1                                                 |
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| 0   | 1   | 0   | 0                                                 |
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| 0   | 1   | 1   | 1                                                 |
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| 1   | 0   | 0   | 0                                                 |
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| 1   | 0   | 1   | 0                                                 |
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| 1   | 1   | 0   | 1                                                 |
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| 1   | 1   | 1   | 1                                                 |