SlideShare a Scribd company logo
1 of 5
Download to read offline
Boolean type
Dmytro Mitin
https://stepik.org/course/49181
December 2018
Dmytro Mitin Boolean type
Boolean type
Haskell
import Prelude hiding (Bool, True, False)
data Bool = True | False
Scala
sealed trait Bool
case object True extends Bool
case object False extends Bool
Java
public interface Bool {}
public class True implements Bool {}
public class False implements Bool {}
Dmytro Mitin Boolean type
Boolean type
1 Type Formation
Γ ctx
Γ Bool : ∗
2 Constructors
Γ ctx
Γ true : Bool
Γ ctx
Γ false : Bool
3 Eliminator
Γ c1 : C Γ c2 : C
Γ, x : Bool if(x)(c1, c2) : C
x match { case True => c1; case False => c2 }
Dmytro Mitin Boolean type
Boolean type
4 Computation rules (”β-reduction“)
Γ c1 : C Γ c2 : C
Γ, x : Bool if(true)(c1, c2) ≡ c1 : C
Γ c1 : C Γ c2 : C
Γ, x : Bool if(false)(c1, c2) ≡ c2 : C
5 Uniqueness principle (”η-conversion“)
Dmytro Mitin Boolean type
ProvingGround
git clone --recursive https://github.com/siddhartha-gadgil/ProvingGround.git
cd ProvingGround
mill -i mantle.repl
import provingground.HoTT.
import provingground.induction.TLImplicits.
import shapeless.
val Bool = "Boolean" :: Type
val b = "b" :: Bool
val BoolInd = ("true" ::: Bool) |: ("false" ::: Bool) =: Bool
val tru :: fls :: HNil = BoolInd.intros
val recBB = BoolInd.rec(Bool)
val not = recBB(fls)(tru)
not(tru) == fls
val recBBB = BoolInd.rec(Bool ->: Bool)
val and = recBBB(b :-> b)(b :-> fls)
and(tru)(fls) == fls
Dmytro Mitin Boolean type

More Related Content

What's hot

Mcs 10 104 compiler design dec 2014
Mcs 10 104 compiler design dec 2014Mcs 10 104 compiler design dec 2014
Mcs 10 104 compiler design dec 2014
Sreeju Sree
 
3 trig identitiessumdiffsinecosine
3 trig identitiessumdiffsinecosine3 trig identitiessumdiffsinecosine
3 trig identitiessumdiffsinecosine
Media4math
 
Robot Exploration with Combinatorial Auctions
Robot Exploration with Combinatorial AuctionsRobot Exploration with Combinatorial Auctions
Robot Exploration with Combinatorial Auctions
techmonkey4u
 
Alg II 2-7 Transformations
Alg II 2-7 TransformationsAlg II 2-7 Transformations
Alg II 2-7 Transformations
jtentinger
 

What's hot (17)

130701 04-01-2013
130701 04-01-2013130701 04-01-2013
130701 04-01-2013
 
[Question Paper] Object Oriented Programming With C++ (Revised Course) [Janua...
[Question Paper] Object Oriented Programming With C++ (Revised Course) [Janua...[Question Paper] Object Oriented Programming With C++ (Revised Course) [Janua...
[Question Paper] Object Oriented Programming With C++ (Revised Course) [Janua...
 
04 - Scala. Type of natural numbers
04 - Scala. Type of natural numbers04 - Scala. Type of natural numbers
04 - Scala. Type of natural numbers
 
Gram-Schmidt and QR Decomposition (Factorization) of Matrices
Gram-Schmidt and QR Decomposition (Factorization) of MatricesGram-Schmidt and QR Decomposition (Factorization) of Matrices
Gram-Schmidt and QR Decomposition (Factorization) of Matrices
 
Mcs 10 104 compiler design dec 2014
Mcs 10 104 compiler design dec 2014Mcs 10 104 compiler design dec 2014
Mcs 10 104 compiler design dec 2014
 
3 trig identitiessumdiffsinecosine
3 trig identitiessumdiffsinecosine3 trig identitiessumdiffsinecosine
3 trig identitiessumdiffsinecosine
 
Sigma type
Sigma typeSigma type
Sigma type
 
lossless data compression and decompression using simple byte coding
lossless data compression and decompression using simple byte codinglossless data compression and decompression using simple byte coding
lossless data compression and decompression using simple byte coding
 
N4.4
N4.4N4.4
N4.4
 
Logarithm Problems
Logarithm ProblemsLogarithm Problems
Logarithm Problems
 
Shortest Path Search with pgRouting
Shortest Path Search with pgRoutingShortest Path Search with pgRouting
Shortest Path Search with pgRouting
 
Eliminators into dependent types
Eliminators into dependent typesEliminators into dependent types
Eliminators into dependent types
 
19 - Scala. Eliminators into dependent types (induction)
19 - Scala. Eliminators into dependent types (induction)19 - Scala. Eliminators into dependent types (induction)
19 - Scala. Eliminators into dependent types (induction)
 
Fun with automata
Fun with automataFun with automata
Fun with automata
 
Graph theory ppt
Graph theory pptGraph theory ppt
Graph theory ppt
 
Robot Exploration with Combinatorial Auctions
Robot Exploration with Combinatorial AuctionsRobot Exploration with Combinatorial Auctions
Robot Exploration with Combinatorial Auctions
 
Alg II 2-7 Transformations
Alg II 2-7 TransformationsAlg II 2-7 Transformations
Alg II 2-7 Transformations
 

More from Roman Brovko

Bare metal training_06_I2C
Bare metal training_06_I2CBare metal training_06_I2C
Bare metal training_06_I2C
Roman Brovko
 
Bare metal training_05_uart
Bare metal training_05_uartBare metal training_05_uart
Bare metal training_05_uart
Roman Brovko
 
подготовка рабочего окружения
подготовка рабочего окруженияподготовка рабочего окружения
подготовка рабочего окружения
Roman Brovko
 

More from Roman Brovko (20)

Individual task Networking
Individual task NetworkingIndividual task Networking
Individual task Networking
 
Networking essentials lect3
Networking essentials lect3Networking essentials lect3
Networking essentials lect3
 
Gl embedded starterkit_ethernet
Gl embedded starterkit_ethernetGl embedded starterkit_ethernet
Gl embedded starterkit_ethernet
 
Networking essentials lect2
Networking essentials lect2Networking essentials lect2
Networking essentials lect2
 
Networking essentials lect1
Networking essentials lect1Networking essentials lect1
Networking essentials lect1
 
Bare metal training_07_spi_flash
Bare metal training_07_spi_flashBare metal training_07_spi_flash
Bare metal training_07_spi_flash
 
Bare metal training_06_I2C
Bare metal training_06_I2CBare metal training_06_I2C
Bare metal training_06_I2C
 
Glesk worshop
Glesk worshopGlesk worshop
Glesk worshop
 
Bare metal training_05_uart
Bare metal training_05_uartBare metal training_05_uart
Bare metal training_05_uart
 
Bare metal training_04_adc_temp_sensor
Bare metal training_04_adc_temp_sensorBare metal training_04_adc_temp_sensor
Bare metal training_04_adc_temp_sensor
 
Bare metal training_03_timers_pwm
Bare metal training_03_timers_pwmBare metal training_03_timers_pwm
Bare metal training_03_timers_pwm
 
Bare metal training_02_le_ds_and_buttons
Bare metal training_02_le_ds_and_buttonsBare metal training_02_le_ds_and_buttons
Bare metal training_02_le_ds_and_buttons
 
Bare metal training_01_hello_world
Bare metal training_01_hello_worldBare metal training_01_hello_world
Bare metal training_01_hello_world
 
Bare metal training_00_prerequisites
Bare metal training_00_prerequisitesBare metal training_00_prerequisites
Bare metal training_00_prerequisites
 
C language lect_23_advanced
C language lect_23_advancedC language lect_23_advanced
C language lect_23_advanced
 
C language lect_22_advanced
C language lect_22_advancedC language lect_22_advanced
C language lect_22_advanced
 
C language lect_21_advanced
C language lect_21_advancedC language lect_21_advanced
C language lect_21_advanced
 
подготовка рабочего окружения
подготовка рабочего окруженияподготовка рабочего окружения
подготовка рабочего окружения
 
C language lect_20_advanced
C language lect_20_advancedC language lect_20_advanced
C language lect_20_advanced
 
C language lect_19_basics
C language lect_19_basicsC language lect_19_basics
C language lect_19_basics
 

Recently uploaded

Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
drm1699
 

Recently uploaded (20)

Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
 
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
 
GraphSummit Milan - Neo4j: The Art of the Possible with Graph
GraphSummit Milan - Neo4j: The Art of the Possible with GraphGraphSummit Milan - Neo4j: The Art of the Possible with Graph
GraphSummit Milan - Neo4j: The Art of the Possible with Graph
 
Rapidoform for Modern Form Building and Insights
Rapidoform for Modern Form Building and InsightsRapidoform for Modern Form Building and Insights
Rapidoform for Modern Form Building and Insights
 
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdfThe Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
 
Evolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI EraEvolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI Era
 
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
 
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
Auto Affiliate  AI Earns First Commission in 3 Hours..pdfAuto Affiliate  AI Earns First Commission in 3 Hours..pdf
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeCon
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
 
From Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST APIFrom Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST API
 
Transformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksTransformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with Links
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdf
 
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale IbridaUNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test Automation
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdf
 
Software Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringSoftware Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements Engineering
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AI
 
From Knowledge Graphs via Lego Bricks to scientific conversations.pptx
From Knowledge Graphs via Lego Bricks to scientific conversations.pptxFrom Knowledge Graphs via Lego Bricks to scientific conversations.pptx
From Knowledge Graphs via Lego Bricks to scientific conversations.pptx
 
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
 

03 - Scala. Boolean type

  • 2. Boolean type Haskell import Prelude hiding (Bool, True, False) data Bool = True | False Scala sealed trait Bool case object True extends Bool case object False extends Bool Java public interface Bool {} public class True implements Bool {} public class False implements Bool {} Dmytro Mitin Boolean type
  • 3. Boolean type 1 Type Formation Γ ctx Γ Bool : ∗ 2 Constructors Γ ctx Γ true : Bool Γ ctx Γ false : Bool 3 Eliminator Γ c1 : C Γ c2 : C Γ, x : Bool if(x)(c1, c2) : C x match { case True => c1; case False => c2 } Dmytro Mitin Boolean type
  • 4. Boolean type 4 Computation rules (”β-reduction“) Γ c1 : C Γ c2 : C Γ, x : Bool if(true)(c1, c2) ≡ c1 : C Γ c1 : C Γ c2 : C Γ, x : Bool if(false)(c1, c2) ≡ c2 : C 5 Uniqueness principle (”η-conversion“) Dmytro Mitin Boolean type
  • 5. ProvingGround git clone --recursive https://github.com/siddhartha-gadgil/ProvingGround.git cd ProvingGround mill -i mantle.repl import provingground.HoTT. import provingground.induction.TLImplicits. import shapeless. val Bool = "Boolean" :: Type val b = "b" :: Bool val BoolInd = ("true" ::: Bool) |: ("false" ::: Bool) =: Bool val tru :: fls :: HNil = BoolInd.intros val recBB = BoolInd.rec(Bool) val not = recBB(fls)(tru) not(tru) == fls val recBBB = BoolInd.rec(Bool ->: Bool) val and = recBBB(b :-> b)(b :-> fls) and(tru)(fls) == fls Dmytro Mitin Boolean type