100% found this document useful (2 votes)
4 views

Network Programming With Rust 1st Edition Abhishek Chanda pdf download

The document is an overview of the book 'Network Programming with Rust' by Abhishek Chanda, which focuses on building network servers and clients using Rust's memory-safety and concurrency features. It includes a detailed table of contents outlining various chapters covering topics such as client/server networking, TCP/UDP programming, data serialization, application layer protocols, and security. The book is aimed at software engineers interested in developing networking applications with Rust and provides resources for further learning and example code downloads.

Uploaded by

panikokuna7y
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
4 views

Network Programming With Rust 1st Edition Abhishek Chanda pdf download

The document is an overview of the book 'Network Programming with Rust' by Abhishek Chanda, which focuses on building network servers and clients using Rust's memory-safety and concurrency features. It includes a detailed table of contents outlining various chapters covering topics such as client/server networking, TCP/UDP programming, data serialization, application layer protocols, and security. The book is aimed at software engineers interested in developing networking applications with Rust and provides resources for further learning and example code downloads.

Uploaded by

panikokuna7y
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 66

Network Programming With Rust 1st Edition

Abhishek Chanda download

https://textbookfull.com/product/network-programming-with-
rust-1st-edition-abhishek-chanda/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Programming WebAssembly with Rust 1st Edition Kevin


Hoffman

https://textbookfull.com/product/programming-webassembly-with-
rust-1st-edition-kevin-hoffman/

Programming Rust 1st Edition Jim Blandy

https://textbookfull.com/product/programming-rust-1st-edition-
jim-blandy/

The Rust Programming Language Covers Rust 2018 Steve


Klabnik

https://textbookfull.com/product/the-rust-programming-language-
covers-rust-2018-steve-klabnik/

Learning Network Programming with Java 1st Edition


Reese Richard M

https://textbookfull.com/product/learning-network-programming-
with-java-1st-edition-reese-richard-m/
The Rust Programming Language 1st Edition Steve Klabnik

https://textbookfull.com/product/the-rust-programming-
language-1st-edition-steve-klabnik/

Asynchronous Programming in Rust 1st Edition Carl


Fredrik Samson

https://textbookfull.com/product/asynchronous-programming-in-
rust-1st-edition-carl-fredrik-samson/

Practical Network Automation Leverage the power of


Python and Ansible to optimize your network 1st Edition
Abhishek Ratan

https://textbookfull.com/product/practical-network-automation-
leverage-the-power-of-python-and-ansible-to-optimize-your-
network-1st-edition-abhishek-ratan/

Programming Rust, 2nd Edition (Early Release) Jim


Blandy

https://textbookfull.com/product/programming-rust-2nd-edition-
early-release-jim-blandy/

The Rust Programming Language 2nd Edition Steve Klabnik

https://textbookfull.com/product/the-rust-programming-
language-2nd-edition-steve-klabnik/
Network Programming with
Rust

Build fast and resilient network servers and clients by


leveraging Rust's memory-safety and concurrency features

Abhishek Chanda

BIRMINGHAM - MUMBAI
Network Programming with Rust
Copyright © 2018 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form
or by any means, without the prior written permission of the publisher, except in the case of brief quotations
embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented.
However, the information contained in this book is sold without warranty, either express or implied. Neither the
author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to
have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products
mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy
of this information.

Commissioning Editor: Merint Mathew


Acquisition Editor: Chaitanya Nair
Content Development Editor: Vikas Tiwari
Technical Editor: Diwakar Shukla
Copy Editor: Safis Editing
Project Coordinator: Ulhas Kambali
Proofreader: Safis Editing
Indexer: Mariammal Chettiyar
Graphics: Tania Dutta
Production Coordinator: Shantanu Zagade

First published: February 2018

Production reference: 1260218

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.

ISBN 978-1-78862-489-3

www.packtpub.com
To my wife, Anasua, for being an amazing partner and friend, and also for all the diagrams in
this book.

To the memory of my mother, Sikha, for her sacrifices and for exemplifying the power of
determination.
mapt.io

Mapt is an online digital library that gives you full access to over 5,000 books and videos, as
well as industry leading tools to help you plan your personal development and advance
your career. For more information, please visit our website.

Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos
from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Mapt is fully searchable

Copy and paste, print, and bookmark content

PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF and
ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a
print book customer, you are entitled to a discount on the eBook copy. Get in touch with us
at service@packtpub.com for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a
range of free newsletters, and receive exclusive discounts and offers on Packt books and
eBooks.
Contributors

About the author


Abhishek Chanda studied computer science at IIEST Shibpur in India and electrical
engineering at Rutgers University. He has lived and worked in multiple countries, working
on distributed systems since 2008 at big companies such as Microsoft as well as a number
smaller start-ups. Currently, he is working with DataSine in London, where he is
responsible for the scalable deployment of infrastructure powering the backend systems of
the DataSine platform. He contributes to a number of open source projects, including Rust.

I would like to thank Packt and their wonderful team for making this possible, especially
Vikas, Chaitanya, Madhunikita, and Diwakar. I am grateful to Pradeep and all the
reviewers for their insightful comments. This book would not have been possible without
the support of my wife, Anasua.
About the reviewer
Pradeep R is a software professional at Gigamon. He is a technology enthusiast passionate
about network programing and security, with wide experience in working on leading
enterprise network switching and routing solutions and in development and deployment of
traditional network security elements. Currently, he is working on next-generation network
pervasive visibility solutions.

He extensively works with C, C++, Python, JavaScript, Perl, and occasionally with Java,
.NET, and Rust. Pradeep has recently reviewed Rust Cookbook.

I would like to thank Vigneshwer Dhinakaran, my brother, who has shown me that
boundaries exists only in our minds and they are meant to be breached. I would also like to
acknowledge with gratitude my mother, Vasanthi, my grandma, Sulochana, and my sister,
Deepika, for their constant encouragement and support.

Packt is searching for authors like you


If you're interested in becoming an author for Packt, please visit authors.packtpub.com and
apply today. We have worked with thousands of developers and tech professionals, just
like you, to help them share their insight with the global tech community. You can make a
general application, apply for a specific hot topic that we are recruiting an author for, or
submit your own idea.
Table of Contents
Preface 1

Chapter 1: Introduction to Client/Server Networking 5


A brief history of networks 6
Layering in networks 7
Addressing in networks 11
How IP routing works 13
How DNS works 16
Common service models 18
Connection-oriented service 18
Connectionless service 20
The network programming interface in Linux 20
Summary 26
Chapter 2: Introduction to Rust and its Ecosystem 27
The Rust ecosystem 28
Getting started with Rust 29
Introduction to the borrow checker 33
Generics and the trait system 38
Error handling 44
The macro system 48
Syntactic macros 49
Procedural macros 50
Functional features in Rust 51
Higher-order functions 51
Iterators 53
Concurrency primitives 55
Testing 59
Summary 62
Chapter 3: TCP and UDP Using Rust 63
A Simple TCP server and client 64
Table of Contents

A Simple UDP server and client 71


UDP multicasting 73
Miscellaneous utilities in std::net 75
Some related crates 77
Summary 87
Chapter 4: Data Serialization, Deserialization, and Parsing 88
Serialization and deserialization using Serde 89
Custom serialization and deserialization 95
Parsing textual data 101
Parsing binary data 108
Summary 112
Chapter 5: Application Layer Protocols 113
Introduction to RPC 114
Introduction to SMTP 121
Introduction to FTP and TFTP 124
Summary 127
Chapter 6: Talking HTTP in the Internet 128
Introducing Hyper 128
Introducing Rocket 136
Introducing reqwest 155
Summary 159
Chapter 7: Asynchronous Network Programming Using Tokio 160
Looking into the Future 161
Working with streams and sinks 168
Heading to tokio 175
Socket multiplexing in tokio 183
Writing streaming protocols 190
The larger tokio ecosystem 200
Conclusion 203
Chapter 8: Security 204
Securing the web 204
Letsencrypt using Rust 207
OpenSSL using Rust 212

[ ii ]
Table of Contents

Securing tokio applications 217


Cryptography using ring 221
Summary 227
Chapter 9: Appendix 228
Introduction to coroutines and generators 228
How May handles coroutines 232
Awaiting the future 236
Data parallelism 241
Parsing using Pest 246
Miscellaneous utilities 250
Summary 254
Other Books You May Enjoy 255

Index 258

[ iii ]
Preface
Rust has steadily become one of the most important new programming languages in recent
years. Like C or C++, Rust enables the developer to write code that is low-level enough to
make Rust code quickly. And since Rust is memory-safe by design, it does not allow code
that can crash on a null pointer exception. These properties make it a natural choice for
writing low-level networking applications. This book will enable developers to get started
with writing networking applications with Rust.

Who this book is for


This book's target audience is a software engineer who is interested in writing networking
software using Rust.

What this book covers


Chapter 1, Introduction to Client/Server Networking, starts the book with a gentle
introduction to computer networking from the ground up. This includes IP addressing,
TCP/UDP, and DNS. This forms the basis of our discussions in later chapters.

Chapter 2, Introduction to Rust and its Ecosystem, contains an introduction to Rust. This is an
overall introduction that should be good enough to get the reader started. We do assume
some familiarity with programming.

Chapter 3, TCP and UDP Using Rust, dives into using Rust for networking. We start with
basic socket programming using the standard library. We then look at some crates from the
ecosystem that can be used for network programming.

Chapter 4, Data Serialization, Deserialization, and Parsing, explains that an important aspect
of networked computing is handling data. This chapter is an introduction to serializing and
deserializing data using Serde. We also look at parsing using nom and other frameworks.

Chapter 5, Application Layer Protocols, moves up a layer to look at protocols that operate
above TCP/IP. We look at a few crates to work with, such as RPC, SMTP, FTP, and TFTP.
Preface

Chapter 6, Talking HTTP in the Internet, explains that arguably the most common
application of the internet is HTTP. We look at crates such as Hyper and Rocket which are
used for writing HTTP servers and clients.

Chapter 7, Asynchronous Network Programming Using Tokio, looks at the Tokio stack for
asynchronous programming using futures, streams, and event loops.

Chapter 8, Security, delves into securing the services we have described so far. This is using
certificates and secret keys.

Chapter 9, Appendix, discusses a number of crates have appeared that propose alternate
ways of doing things already covered in this book. This includes the async/await syntax,
parsing using Pest, and so on. We will discuss some of these in the appendix.

To get the most out of this book


1. They are either already familiar with Rust or are planning to start learning the
language.
2. They have a commercial background in software engineering using other
programming languages and are aware about the tradeoffs in developing
software using different programming languages.
3. They have a basic familiarity with networking concepts.
4. They can appreciate why distributed systems are important in modern
computing.

Download the example code files


You can download the example code files for this book from your account at
www.packtpub.com. If you purchased this book elsewhere, you can visit
www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

1. Log in or register at www.packtpub.com.


2. Select the SUPPORT tab.
3. Click on Code Downloads & Errata.
4. Enter the name of the book in the Search box and follow the onscreen
instructions.

[2]
Preface

Once the file is downloaded, please make sure that you unzip or extract the folder using the
latest version of:

WinRAR/7-Zip for Windows


Zipeg/iZip/UnRarX for Mac
7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https:/​/​github.​com/
PacktPublishing/​Network-​Programming-​with-​Rust. We also have other code bundles from
our rich catalog of books and videos available at https:/​/​github.​com/​PacktPublishing/​.
Check them out!

Conventions used
There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames,
file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an
example: "The target directory contains compilation artifacts."

A block of code is set as follows:


[package]
name = "hello-rust"
version = "0.1.0"
authors = ["Foo Bar <foo.bar@foobar.com>"]

Any command-line input or output is written as follows:


# cargo new --bin hello-rust

Bold: Indicates a new term, an important word, or words that you see onscreen. For
example, words in menus or dialog boxes appear in the text like this. Here is an example: "It
will not need to call connect for that same connection:"

Warnings or important notes appear like this.

[3]
Preface

Tips and tricks appear like this.

Get in touch
Feedback from our readers is always welcome.

General feedback: Email feedback@packtpub.com and mention the book title in the
subject of your message. If you have questions about any aspect of this book, please email
us at questions@packtpub.com.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you have found a mistake in this book, we would be grateful if you would
report this to us. Please visit www.packtpub.com/submit-errata, selecting your book,
clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we
would be grateful if you would provide us with the location address or website name.
Please contact us at copyright@packtpub.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in
and you are interested in either writing or contributing to a book, please visit
authors.packtpub.com.

Reviews
Please leave a review. Once you have read and used this book, why not leave a review on
the site that you purchased it from? Potential readers can then see and use your unbiased
opinion to make purchase decisions, we at Packt can understand what you think about our
products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com.

[4]
Introduction to Client/Server
1
Networking
This book is an introduction to writing networking applications in Rust. This title begs two
questions: why should anyone care about networking? And why would anyone want to
write networking applications in Rust? We attempt to answer the first question in this
chapter. We will introduce Rust and network programming using Rust in subsequent
chapters. Firstly, in this chapter, we will start with a bit of history and try to understand
how network architecture evolved over the last hundred years. In subsequent sections, we
will see how modern networks are layered and addressed. Afterwards, we will describe
common service models used in networking. We will end with a summary of networking-
related programming interfaces that Linux exposes. Note that this book deliberately ignores
network programming in other operating systems and focuses only on Linux for the sake of
simplicity. While the Rust compiler is platform-agnostic, there can be cases where some
things are different in other platforms compared to Linux. We will point out those
differences as we progress.

In this chapter, we will cover the following topics:

History of networking: why and how networks came into use and how the
internet evolved
Layering in networks: how layering and encapsulation works
Addressing: how networks and individual hosts are uniquely identified on the
internet
How IP routing works
How DNS works
Service models for data delivery
The network programming interface in Linux
Introduction to Client/Server Networking Chapter 1

A brief history of networks


The modern internet has revolutionized how we communicate with one another. However,
it had humble beginnings in the Victorian era. One of the earliest precursors to the internet
was telegraph networks which were operational as early as 1850. Back then, it used to take
10 days to send a message from Europe to North America by sea. Telegraph networks
reduced that to 17 hours. By the late 19th century, the telegraph was a fully successful
communication technology that was used widely in the two world wars. Around that time,
people started building computers to help in cracking enemy codes. Unlike our modern
mobile phones and laptops, those computing machines were often huge and needed
specialized environments to be able to operate smoothly. Thus, it was necessary to put those
in special locations while the operators would sit on a terminal. The terminal needed to be
able to communicate with the computer over short distances. A number of local area
networking technologies enabled this, the most prominent one being Ethernet. Over time,
these networks grew and by the 1960s, some of these networks were being connected with
one another to form a larger network of networks. The Advanced Research Projects
Agency Network (ARPANET) was established in 1969 and it became the first internetwork
that resembles the modern internet. Around 1973, there were a number of such
internetworks all around the world, each using their own protocols and methods for
communication. Eventually, the protocols were standardized so that the networks could
communicate with each other seamlessly. All of these networks were later merged to form
what is the internet today.

Since networks evolved in silos all around the world, they were often organized according
to geographical proximity. A Local Area Network (LAN) is a collection of host machines in
small proximity like a building or a small neighborhood. A Wide Area Network (WAN) is
one that connects multiple neighborhoods; the global internet is at the top of the
hierarchy. The next picture shows a map of the ARPANET in 1977. Each node in this map is
a computer (a server, in today's terms). Most of these were located in large universities like
Stanford or at national laboratories like Lawrence Berkeley (source: https:/​/​commons.
wikimedia.​org/​wiki/​File:Arpanet_​logical_​map,_​march_​1977.​png).

In networking, a Request For Comment (RFC) is a document that


describes how a proposed system should work. These are the first steps
towards standardizing a protocol or a system. The term internet was first
used in RFC 675, which proposed a standard for TCP.

[6]
Introduction to Client/Server Networking Chapter 1

Layering in networks
Computer science often focuses on subdividing a problem into smaller, hopefully
independent components that can be solved in isolation. Once that is done, all that is
needed is a set of rules on how those components should communicate to have a solution to
the larger problem. This set of rules, along with a pre-agreed data format, is called a
protocol. A network is composed of a number of layers, each of which has a fixed purpose.
Thus, each of these layers run one or many protocols, forming a stack of protocols. In the
early days of networking, different people implemented their networks in different ways.
When the internet was conceived, there was a need to make these networks communicate
seamlessly. Since they were constructed differently, this turned out to be difficult.

[7]
Introduction to Client/Server Networking Chapter 1

There was a clear need to agree on standard protocols and interfaces to make the internet
work. The first attempt at standardizing networking protocols was in 1977, which led to the
OSI model. This model has the following layers:

Physical layer: It defines how data is transmitted in the physical medium in


terms of its electrical and physical characteristics. This can either be by wire, fiber
optic, or a wireless medium.
Data link layer: It defines how data is transmitted between two nodes connected
by a physical medium. This layer deals with prioritization between multiple
parties trying to access the wire simultaneously. Another important function of
this layer is to include some redundancy in the transmitted bits to minimize
errors during transmission. This is referred to as coding.
Network layer: It defines how packets (made up of multiple units of data) are
transmitted between networks. Thus, this layer needs to define how to identify
hosts and networks uniquely.
Transport layer: It defines mechanisms to reliably deliver variable length
messages to hosts (in the same or different networks). This layer defines a stream
of packets that the receiver can then listen to.
Session layer: It defines how applications running on hosts should communicate.
This layer needs to differentiate between applications running on the same host
and deliver packets to them.
Presentation layer: It defines common formats for data representation so that
different applications can interlink seamlessly. In some cases, this layer also takes
care of security.
Application layer: It defines how user-centric applications should send and
receive data. An example is the web browser (a user-centric application) using
HTTP (an application layer protocol) to talk to a web server.

The following figure shows a visual representation of this model (source: https:/​/​commons.
wikimedia.​org/​wiki/​File:Osi-​model-​jb.​svg). This also shows two vertical classifications,
the host running the network stack and the physical media (including the wire and the
network device). Each layer has its own data unit, the representation of the information it
works on, and since each layer encapsulates the one below it, the data units encapsulate too.
A number of bits form a frame, a number of frames form a packet, and so on, to the top:

[8]
Introduction to Client/Server Networking Chapter 1

The OSI model and its layers

While OSI was working on standardizing this model, Defense Advanced Research Projects
Agency (DARPA) came up with a full implementation of the much simpler TCP/IP model
(also known as the IP (Internet Protocol) suite). This model has the following layers, from
closest to the physical medium to the farthest:

Hardware interface layer: This is a combination of layers one and two of the OSI
model. This layer is responsible for managing media access control, handling
transmission and reception of bits, retransmission, and coding (some texts on
networking differentiate between the hardware interface layer and the link layer.
This results in a five layer model instead of four. This hardly matters in practice,
though.)
IP layer: This layer corresponds to layer three of the OSI stack. Thus, this layer is
responsible for two major tasks: addressing hosts and networks so that they can
be uniquely identified and given a source and a destination address, and
computing the path between those given a bunch of constraints (routing).
Transport layer: This layer corresponds to layer four of the OSI stack. This layer
converts raw packets to a stream of packets with some guarantees: in-order
delivery (for TCP) and randomly ordered delivery (for UDP).

[9]
Introduction to Client/Server Networking Chapter 1

Application layer: This layer combines layers five to seven of the OSI stack and is
responsible for identifying the process, data formatting, and interfacing with all
user level applications.

Note that the definition of what a particular layer handles changes as we move from one
layer to another. The hardware interface layer handles collection of bits and bytes
transmitted by hosts, the IP layer handles packets (the collection of a number of bytes sent
by a host in a specific format), the transport layer bunches together packets from a given
process on a host to another process on another host to form a segment (for TCP) or
datagram (for UDP), and the application layer constructs application specific
representations from the underlying stream. For each of these layers, the representation of
data that they deal with is called a Protocol Data Unit (PDU) for that layer. As a
consequence of this layering, when a process running on a host wants to send data to
another host, the data must be broken into individual chunks. As the chunk travels from
one layer to another, each layer adds a header (sometimes a trailer) to the chunk, forming
the PDU for that layer. This process is called encapsulation. Thus, each layer provides a set
of services to layers above it, specified in the form of a protocol.

The modern internet exhibits a form of geographical hierarchy. Imagine a number of homes
which are served by a number of Internet Service Providers (ISPs). Each of these homes
is in a LAN (either via Ethernet, or more commonly, Wi-Fi). The ISP connects many such
LANs in a WAN. Each ISP has one or many WANs that they connect to form their own
network. These larger networks, spanning cities, which are controlled by a single business
entity, are called Administrative Systems (AS). Routing between multiple ISPs is often
more complex than regular IP routing since they have to take into account things like
trading agreements and so on. This is handled by specialized protocols like the Border
Gateway Protocol (BGP).

As mentioned before, one of the earliest and most successful networking technologies is
Ethernet. First introduced in 1974, it quickly became the predominant technology for LAN
and WAN due to its low cost and relative ease of maintenance. Ethernet is a shared media
protocol where all the hosts must use the same physical medium to send and receive
frames. Frames are delivered to all hosts, which will check if the destination MAC address
(these addresses will be described in the next section) matches its own address. If it does,
the frame is accepted, otherwise, it is discarded. Since the physical medium can only carry
one signal at any given moment, there is a probability that frames might collide in transit. If
that does occur, the sender can sense the collision by sensing transmission from other hosts
while it is transmitting its frame. It then aborts the transmission and sends a jam signal to
let other hosts know of the collision. Then, it waits for an exponentially backed off amount
of time and retries the transmission. After a fixed number of attempts, it gives up if the
transmission does not succeed.

[ 10 ]
Introduction to Client/Server Networking Chapter 1

This scheme is called carrier-sense multiple access with collision detection (CSMA/CD).
One problem with Ethernet is its relatively short range. Depending on the physical wiring
technology used, the maximum length of an Ethernet segment varies between 100 m to 500
m. Thus, multiple segments must be connected to form a larger network. The most common
way of doing that is using layer two switches between two adjacent Ethernet segments.
Each port of these switches forms different collision domains, reducing the overall
probability of collisions. These switches can also monitor traffic to learn which MAC
addresses are on which ports so that eventually, they will send out frames for that MAC
address only on that port (referred to as a learning switch). In modern homes, Wi-Fi is often
the dominant LAN technology compared to Ethernet.

Addressing in networks
We have seen why it is important to identify hosts and networks uniquely to be able to
deliver packets reliably. Depending on the scale, there are three major ways of doing this;
we will discuss each of those in this section. The end to end process of IP routing will be
discussed in the next section. One interesting fact to note is that for each of these addressing
modes, one or more addresses are reserved for special use. Often, these are marked by a
known set of bits being on or off in a known pattern:

Ethernet address: This is also known as a Media Access Control (MAC) address.
It is a 48-bit long unique identifier assigned to a network device (usually stored
on the card) that is used to identify it in a network segment. Usually, these are
programmed by the network card manufacturer, but all modern OS's allow one
to modify it. The standard way of writing Ethernet addresses are in six groups of
two hexadecimal digits (01-23-45-67-89-ab-cd-ef). Another common way is to use
a colon to separate the digits (01:23:45:67:89:ab:cd:ef). A few special sequences of
bits are reserved for addressing special cases: the sender can request that an
Ethernet frame should be received by all hosts in that segment by setting the least
significant bit of the first octet to 1; this is called multicasting. If that particular bit
is set to 0, the frame should be delivered to only one receiver. Today, these are
used widely with Ethernet and Wi-Fi.

[ 11 ]
Introduction to Client/Server Networking Chapter 1

IP address: This is an address assigned to each device in an IP network. The


original IP address standard (IPv4) defined 32-bit addresses in 1980. However, by
1995, it was obvious that the total number of available addresses on the internet is
not enough to cover all devices. This led to the development of IPv6, which
expanded the address space to 128 bits. The standard way of dealing with a
group of IP addresses is using the CIDR notation, for example, 192.168.100.1/26
(IPv4). The decimal number after the slash counts the number of leading 1s in the
network mask. Thus, in this particular case, there are 2^(32-26) = 64 addresses in
the network starting from 192.168.100.0 to 192.168.100.63. The Internet Assigned
Numbers Authority (IANA) assigns blocks of publicly routable IP addresses to
organizations. A number of IPv4 and v6 addresses are reserved for various
purposes like addressing in private networks and so on. In a home network
(which will always use special private range addresses), these are assigned by the
Dynamic Host Configuration Protocol (DHCP) by the Wi-Fi router.
Autonomous system number: This is a 32-bit number used to uniquely identify
autonomous systems. Like IP addresses, these are assigned and maintained by
the IANA.

Apart from these, communication between hosts often uses a port number to distinguish
between processes. When the OS allocates a specific port to a process, it updates its
database of the mapping between process identifier and port number. Thus, when it
receives incoming packets on that port, it knows what process to deliver those packets to. In
case the process has exited by that time, the OS will drop the packets and in the case of TCP,
initiate closing of the connection. In the subsequent sections, we will see how TCP works in
practice.

A range of port numbers between 0 and 1024 are reserved for common
services by the OS. Other applications are free to request any port above
1024.

[ 12 ]
Introduction to Client/Server Networking Chapter 1

How IP routing works


To understand how IP routing works, we must first begin with the structure of IPv4
addresses. As described in the last section, these are 32 bits in length. They are written in a
dotted decimal notation in groups of 4 bytes (for example, 192.168.122.5). A given number
of bits in that network prefix is used to identify the network where the packet should be
delivered, and the rest of the bits identify the particular host. Thus, all hosts in the same
network must have the same prefix. Conventionally, the prefix is described in the CIDR
notation with the starting address and the number of bits in the network portion of the
address separated by a slash (192.168.122.0/30). The number can then be used to find out
how many addresses are available for hosts in the network (in this case, 2^(32-30) = 4).
Given an IP address and a prefix, the network address can be extracted by bitwise-ANDing
the address with a mask of all 1s in the network portion. Calculating the host address is just
the reverse; we will need to AND with the network mask's logical negation (the host mask),
which has all 0s in the network portion and all 1s in the host portion. Given an address and
a prefix like 192.168.122.5/27, we will compute these as shown in the following figure. Thus,
for the given CIDR, the network address is 192.168.122.0 and the host address is 0.0.0.5:

CIDR to network and host address conversion

As described before, each IP network will have a reserved broadcast


address that can be used for a host to send a message to all hosts in that
network. This can be computed by ORing with the host mask. In our
example, this comes out to be 192.168.122.31. Note that the network
address can not be a valid host address.

[ 13 ]
Introduction to Client/Server Networking Chapter 1

There are two broad classes of IP address; some blocks of addresses can be routed in the
public internet, these are called public IP addresses. Some other blocks can only be used in
private networks that do not directly interface with the internet, these are called private
addresses. If a router on the internet receives a packet that is destined for a private IP
address, it will have to drop that packet. Other than these two, IP addresses are also
classified on various parameters: some are reserved for documentation only (192.0.2.0/24),
some are reserved for point to point communication between two hosts (169.254.0.0/16), and
so on. The Rust standard library has convenience methods to classify IP addresses
according to their types.

All routers maintain a routing table which maps prefixes to the outgoing interface of the
router (while a router administrator might decide to store individual addresses instead of
prefixes, this will quickly lead to a large routing table in a busy router). An entry in the table
basically says If a packet needs to go to this network, it should be sent on this interface. The next
host that receives the packet might be another router or the destination host. How do
routers figure out this table? Multiple routers run routing protocols between those which
compute those tables. Some common examples are OSPF, RIP, and BGP. Given these
primitives, the actual routing mechanism is fairly simple, as shown in the next diagram.

An interesting aspect of IP is the use of the Time To Live (TTL) field, this is also known as
hop limit. The host sends out packets with a fixed value of TTL (usually 64). Each router the
packet crossed decreases the TTL. When it reaches 0, the packet is discarded. This
mechanism ensures that packets are not stuck in an infinite loop between routers:

General routing algorithm

[ 14 ]
Introduction to Client/Server Networking Chapter 1

Internet Control Message Protocol (ICMP) is used to exchange


operational information between network devices. In the preceding
example, one or multiple routers might decide to send back an ICMP error
if they are configured to do so.

Note that while trying to match the prefix to routes in the routing table, multiple routes
might match. If that happens, the router must select the most specific match and use that for
forwarding. Since the most specific routes will have the maximum number of leading 1s,
and hence the largest prefix, this is called the longest prefix match. Say our router has the
following routing table, as shown in the diagram. eth1, eth2, and eth3 are three network
interfaces attached to our router, each having a different IP address in different networks:

Longest prefix matching example

At this point, if our device gets a packet that has a destination address set to 192.168.1.33, all
three prefixes have this address but the last one is the largest of the three. So, the packet will
go out through eth3.

A lot of what we described so far about IPv4 addresses does not change for IPv6, except, of
course, it has a larger address space of 128 bits. In this case, the length of the network mask
and the host mask depends on the address type.

One might be wondering, how do routers construct the routing table? As always, there are
protocols to help with that. Routing protocols are of two major types: interior gateway
protocols which are used for routing inside an autonomous system, and exterior gateway
protocols which are used in routing between autonomous systems; an example of the latter
is BGP. Interior gateway protocols can again be of two types, depending on how they look
at the whole network. In link state routing, each router participating in the protocol
maintains a view of the whole network topology. In distance vector routing, each router
only knows about its one hop neighbors. An example of the former is the Routing
Information Protocol (RIP) and of the latter is Open Shortest Path First (OSPF). Details
about these are beyond the scope of this book. However, we can note that the common
theme among all the routing protocols is that they work by exchanging information
between routers. Thus, they have their own packet formats for encapsulating that
information.

[ 15 ]
Introduction to Client/Server Networking Chapter 1

How DNS works


Note that it's impossible for anyone to remember the IP address of each and every service
on the internet. Fortunately, there is a protocol for that! The Domain Name Server (DNS)
solves this problem by maintaining a map of a human readable hierarchical name to the IP
address of the service in a distributed database. Thus, when a user enters http:/​/​www.
google.​com in their browser and hits the Enter key, the first step is to look up the IP address
of the name www.google.com using DNS. The next figure shows the steps necessary in such a
query. In this discussion, we will use the names local DNS resolver, local DNS server, and
local DNS nameserver interchangeably:

How DNS works

An application that needs to resolve a name will use a system call like getaddrinfo. This
essentially asks the OS to go ahead and resolve the name. This step is not shown in the
figure. The next steps are as follows:

1. Typically, each computer in a network will have a local DNS server configured in
the file /etc/resolv.conf. In most cases, this points to the ISP's DNS server.
This might also point to the home Wi-Fi router's DNS server. In that case, the
DNS will transparently proxy requests to the ISP's DNS server. The OS will then
query that server, asking the IP of the given name www.google.com.

[ 16 ]
Introduction to Client/Server Networking Chapter 1

2. The local DNS server will, in turn, ask the same question to a pre-populated list
of root name servers. These servers are maintained by ICANN and their
addresses are well-known. They maintain addresses for the top level domain
name servers. This means that they know the addresses of namesevers for the
.com domain.
3. In this step, the root name server replies with the addresses of TLD name servers
for the .com domain. These servers maintain a list of addresses for name servers
in their own domains.
4. The local DNS server then contacts one of those and asks the same question.
5. The TLD name server replies back with the addresses of servers in the
google.com domain. An admin of the google.com domain maintains a bunch
of nameservers for that domain. Those nameservers have full authority over all
records in that domain, and each of those records are marked authoritative to
indicate that.
6. The local DNS server then asks one of those the same question.
7. (Hopefully) that server does know the address of www.google.com. If it does, it
prepares a response, marks it as authoritative, and sends it back to the local DNS
server. The answer can also have a time to live associated with it so that the local
DNS server can cache it for future use and evict it after the given time is over. If it
does not, name resolution will fail and it will send back a special response called
NXDOMAIN.
8. The local DNS server then sends back the same response to the OS, which
delivers it to the application. The local server marks the response as non-
authoritative, indicating that it got that answer from somewhere else.

Interestingly, DNS is like asking a friend for someone's address, who then says I do not
know, but I know someone who knows someone who knows someone who might know. I can find out
for you! They then go and ask around and return with a reply.

DNS packets are often very small since they have a small question and answer along with
some control information, and since DNS does not need very high reliability from the
transport layer, this makes it an ideal candidate for using UDP (described in the next
section). However, most implementations include an option to fall back to TCP if the
transport is too unreliable.

[ 17 ]
Introduction to Client/Server Networking Chapter 1

DNS supports multiple record types for various things. The A record maps
a name to an IPv4 address, AAAA record maps a name to a IPv6 address,
and so on. Reverse lookups are supported using PTR records.

Common service models


For two hosts to communicate via a network, they will need to send messages to each other.
There are two models of exchanging messages, and each has specific usecases where they
work best. In this section, we will explore these. Note that the service models are properties
of the protocols and that they set expectations around what a consumer should expect from
them.

Connection-oriented service
The service a protocol provides to its consumers is connection oriented when each party
involved negotiates a virtual connection before sending the actual data. During the setup
process, a number of parameters about the connection must be agreed upon. This is
analogous to the older wired telephone systems, where a dedicated connection is set up
between the two hosts. In modern networks, an example is TCP. The PDU for TCP is a
segment, which consists of a header and a data section. The header has a few fields which
are used to transition between states of the protocol state machine. The next figure shows
what the TCP header looks like in practice. Each of the rows in this figure are of 32 bits
(thus, each row is two octets), and some are divided into multiple segments:

TCP header format

[ 18 ]
Introduction to Client/Server Networking Chapter 1

We will look at a few of these which are used for manipulating the connection between
hosts:

Control bits (flags) are a set of 9 bits that are used for various purposes. The flags
of interest here are SYN, ACK, FIN, and RST. SYN triggers a synchronization of
sequence numbers. The ACK flag indicates that the receiver should care about the
corresponding acknowledgment number. The FIN flag starts the process of
tearing down a connection. The RST flag resets the connection in case of an error.
The sequence number is a 32-bit field which is used to reorder messages at the
receiver. When the SYN flag is set (which should be the case only for the first
packet in a connection), the sequence number is the initial sequence number;
otherwise, it is the sequence number accumulated so far.
The acknowledgement number is a 32-bit field which is used to enable reliable
delivery of messages. If the ACK flag is set, this value is the next sequence
number that the sender is expecting.

Before two hosts running TCP can start exchanging data, they must do a three-way
handshake to establish a connection. This works like this: the client that wants to initiate
communication sends a SYN packet to the server. The sequence number is set to a random
value and the SYN flag is set to 1. The server responds with a packet that has both SYN and
ACK set to 1. This packet has the acknowledgment number set to one more than what it got
from the client, and the sequence number is set to a random number. Finally, the client
responds with a packet that has the ACK flag set, the sequence number set to the received
acknowledgement number in the last step, and the acknowledgement number is set to one
more than the sequence number in the previous step. After this is done successfully, both
the client and the server have agreed on sequence and acknowledgement numbers. The
advantage of this model is that is has a reliable connection where both the sender and the
receiver knows what to expect. The sender can tune the rate of sending data, depending on
how fast or slow the receiver is or how congested the network is. The disadvantage here is
the higher connection setup costs. Assuming it takes 100 ms to send a packet to a host in
another continent, we will need to exchange at least 3 packets before we can begin sending
data. That amounts to a delay of 300 ms. While this might not look like a lot, remember that
at any given point, a laptop being used for accessing Facebook might have thousands of
connections open to servers all over the world. The connection oriented service model
works fine for a large number of use cases, but there are a few cases where the overhead is
either significant or unnecessary. An example is video streaming. In this case, a few missing
packets do not cause a huge problem since no one notices a small number of misaligned
pixels in the video. These applications prefer a connectionless model, as described below.

[ 19 ]
Another Random Document on
Scribd Without Any Related Topics
Another classification of Propositions divides them in two classes
as follows: (1) Universal; (2) Particular.
A Universal Proposition is one in which the whole quantity of the
Subject is involved in the assertion or denial of the Predicate. For
instance: "All men are liars," by which is affirmed that all of the
entire race of men are in the category of liars, not some men but all
the men that are in existence. In the same way the Proposition: "No
men are immortal" is Universal, for it is a universal denial.
A Particular Proposition is one in which the affirmation or denial of
the Predicate involves only a part or portion of the whole of the
Subject, as for instance: "Some men are atheists," or "Some women
are not vain," in which cases the affirmation or denial does not
involve all or the whole of the Subject. Other examples are: "A few
men," etc.; "many people," etc.; "certain books," etc.; "most
people," etc.
Hyslop says: "The signs of the Universal Proposition, when
formally expressed, are all, every, each, any, and whole or words
with equivalent import." The signs of Particular Propositions are also
certain adjectives of quantity, such as some, certain, a few, many,
most or such others as denote at least a part of a class.
The subject of the Distribution of Terms in Propositions is
considered very important by Logicians, and as Hyslop says: "has
much importance in determining the legitimacy, or at least the
intelligibility, of our reasoning and the assurance that it will be
accepted by others." Some authorities favor the term, "Qualification
of the Terms of Propositions," but the established usage favors the
term "Distribution."
The definition of the Logical term, "Distribution," is: "The
distinguishing of a universal whole into its several kinds of species;
the employment of a term to its fullest extent; the application of a
term to its fullest extent, so as to include all significations or
applications." A Term of a Proposition is distributed when it is
employed in its fullest sense; that is to say, when it is employed so
as to apply to each and every object, person or thing included under
it. Thus in the proposition, "All horses are animals," the term horses
is distributed; and in the proposition, "Some horses are
thoroughbreds," the term horses is not distributed. Both of these
examples relate to the distribution of the subject of the proposition.
But the predicate of a proposition also may or may not be
distributed. For instance, in the proposition, "All horses are animals,"
the predicate, animals, is not distributed, that is, not used in its
fullest sense, for all animals are not horses—there are some animals
which are not horses and, therefore, the predicate, animals, not
being used in its fullest sense is said to be "not distributed." The
proposition really means: "All horses are some animals."
There is however another point to be remembered in the
consideration of Distribution of Terms of Propositions, which Brooks
expresses as follows: "Distribution generally shows itself in the form
of the expression, but sometimes it may be determined by the
thought. Thus if we say, 'Men are mortal,' we mean all men, and the
term men is distributed. But if we say 'Books are necessary to a
library,' we mean, not 'all books' but 'some books.' The test of
distribution is whether the term applies to 'each and every.' Thus
when we say 'men are mortal,' it is true of each and every man that
he is mortal."
The Rules of Distribution of the Terms of Proposition are as
follows:
1. All universals distribute the subject.
2. All particulars do not distribute the subject.
3. All negatives distribute the predicate.
4. All affirmatives do not distribute the predicate.
The above rules are based upon logical reasoning. The reason for
the first two rules is quite obvious, for when the subject is universal,
it follows that the whole subject is involved; when the subject is
particular it follows that only a part of the subject is involved. In the
case of the third rule, it will be seen that in every negative
proposition the whole of the predicate must be denied the subject,
as for instance, when we say: "Some animals are not horses," the
whole class of horses is cut off from the subject, and is thus
distributed. In the case of the fourth rule, we may readily see that in
the affirmative proposition the whole of the predicate is not denied
the subject, as for instance, when we say that: "Horses are animals,"
we do not mean that horses are all the animals, but that they are
merely a part or portion of the class animal—therefore, the
predicate, animals, is not distributed.
In addition to the forms of Propositions given there is another
class of Propositions known as Definitive or Substitutive Propositions,
in which the Subject and the Predicate are exactly alike in extent
and rank. For instance, in the proposition, "A triangle is a polygon of
three sides" the two terms are interchangeable; that is, may be
substituted for each other. Hence the term "substitutive." The term
"definitive" arises from the fact that the respective terms of this kind
of a proposition necessarily define each other. All logical definitions
are expressed in this last mentioned form of proposition, for in such
cases the subject and the predicate are precisely equal to each
other.
CHAPTER X.
IMMEDIATE REASONING
In the process of Judgment we must compare two concepts and
ascertain their agreement of disagreement. In the process of
Reasoning we follow a similar method and compare two judgments,
the result of such comparison being the deduction of a third
judgment.
The simplest form of reasoning is that known as Immediate
Reasoning, by which is meant the deduction of one proposition from
another which implies it. Some have defined it as: "reasoning
without a middle term." In this form of reasoning only one
proposition is required for the premise, and from that premise the
conclusion is deduced directly and without the necessity of
comparison with any other term of proposition.
The two principal methods employed in this form of Reasoning
are; (1) Opposition; (2) Conversion.
Opposition exists between propositions having the same subject
and predicate, but differing in quality or quantity, or both. The Laws
of Opposition are as follows:
I. (1) If the universal is true, the particular is true. (2) If the
particular is false, the universal is false. (3) If the universal is false,
nothing follows. (4) If the particular is true, nothing follows.
II. (1) If one of two contraries is true, the other is false. (2) If one
of two contraries is false, nothing can be inferred. (3) Contraries are
never both true, but both may be false.
III. (1) If one of two sub-contraries is false, the other is true. (2)
If one of two sub-contraries is true, nothing can be inferred
concerning the other. (3) Sub-contraries can never be both false, but
both may be true.
IV. (1) If one of two contradictories is true, the other is false. (2)
If one of two contradictories is false, the other is true. (3)
Contradictories can never be both true or both false, but always one
is true and the other is false.
In order to comprehend the above laws, the student should
familiarize himself with the following arrangement, adopted by
logicians as a convenience:

Affirmative (A)
Universal
Negative (E)
Propositions
Affirmative (I)
Particular
Negative (O)

Examples of the above: Universal Affirmative (A): "All men are


mortal;" Universal Negative (E): "No man is mortal;" Particular
Affirmative (I): "Some men are mortal;" Particular Negative (O):
"Some men are not mortal."
The following examples of abstract propositions are often used by
logicians as tending toward a clearer conception than examples such
as given above:
(A) "All A is B."
(I) "Some A is B."
(E) "No A is B."
(O) "Some A is not B."
These four forms of propositions bear certain logical relations to
each other, as follows:
A and E are styled contraries. I and O are sub-contraries; A and I
and also E and O are called subalterns; A and O and also I and E are
styled contradictories.
A close study of these relations, and the symbols expressing them,
is necessary for a clear comprehension of the Laws of Opposition
stated a little further back, as well as the principles of Conversion
which we shall mention a little further on. The following chart, called
the Square of Opposition, is also employed by logicians to illustrate
the relations between the four classes of propositions:

Conversion is the process of immediate reasoning by which we


infer from a given proposition another proposition having the
predicate of the original for its subject and the subject of the original
for its predicate; or stated in a few words: Conversion is the
transposition of the subject and predicate of a proposition. As Brooks
states it: "Propositions or judgments are converted when the subject
and predicate change places in such a manner that the resulting
judgment is an inference from the given judgment." The new
proposition, resulting from the operation or Conversion, is called the
Converse; the original proposition is called the Convertend.
The Law of Conversion is that: "No term must be distributed in the
Converse that is not distributed in the Convertend." This arises from
the obvious fact that nothing should be affirmed in the derived
proposition than there is in the original proposition.
There are three kinds of Conversion; viz: (1) Simple Conversion;
(2) Conversion by Limitation; (3) Conversion by Contraposition.
In Simple Conversion there is no change in either quality or
quantity. In Conversion by Limitation the quality is changed from
universal to particular. In Conversion by Negation the quality is
changed but not the quantity. Referring to the classification tables
and symbols given in the preceding pages of this chapter, we may
now proceed to consider the application of these methods of
Conversion to each of the four kinds of propositions; as follows:
The Universal Affirmative (symbol A) proposition is converted by
Limitation, or by a change of quality from universal to particular. The
predicate not being "distributed" in the convertend, we must not
distribute it in the converse by saying "all." Thus in this case we
must convert the proposition, "all men are mortal" (A), into "some
mortals are men" (I).
The Universal Negative (symbol E) is converted by Simple
Conversion, in which there is no change in either quality or quantity.
For since both terms of "E" are distributed, they may both be
distributed in the converse without violating the law of conversion.
Thus "No man is mortal" is converted into: "No mortals are men."
"E" is converted into "E."
The Particular Affirmative (symbol I) is also converted by Simple
Conversion in which there is no change in either quality or quantity.
For since neither term is distributed in "I," neither term may be
distributed in the converse, and the latter must remain "I." For
instance; the proposition: "Some men are mortal" is converted into
the proposition, "Some mortals are men."
The Particular Negative (symbol O) is converted by Conversion by
Negation, in which the quality is changed but not the quantity. Thus
in converting the proposition: "Some men are not mortal," we must
not say "some mortals are not men," for in so doing we would
distribute men in the predicate, where it is not distributed in the
convertend. Avoiding this, we transfer the negative particle from the
copula to the predicate so that the convertend becomes "I" which is
converted by Simple Conversion. Thus we transfer "Some men are
not mortal" into "Some men are not-mortal" from which we easily
convert (by simple Conversion) the proposition: "Some not-mortals
are men."
It will be well for students, at this point, to consider the three
following Fundamental Laws of Thought as laid down by the
authorities, which are as follows:
The Law of Identity, which states that: "The same quality or thing
is always the same quality or thing, no matter how different the
conditions in which it occurs."
The Law of Contradiction, which states that: "No thing can at the
same time and place both be and not be."
The Law of Excluded Middle, which states that: "Everything must
either be or not be; there is no other alternative or middle course."
Of these laws, Prof. Jevons, a noted authority, says: "Students are
seldom able to see at first their full meaning and importance. All
arguments may be explained when these self-evident laws are
granted; and it is not too much to say that the whole of logic will be
plain to those who will constantly use these laws as the key."
CHAPTER XI.
INDUCTIVE REASONING
Inductive Reasoning, as we have said, is the process of
discovering general truth from particular truths, or inferring general
laws from particular facts. Thus, from the experience of the
individual and the race regarding the particular truth that each and
every man under observation has been observed to die sooner or
later, it is inferred that all men die, and hence, the induction of the
general truth that "All men must die." Or, as from experience we
know that the various kinds of metals expand when subjected to
heat, we infer that all metals are subject to this law, and that
consequently we may arrive by inductive reasoning at the conclusion
that: "All metals expand when subjected to heat." It will be noticed
that the conclusion arrived at in this way by Inductive Reasoning
forms the fundamental premise in the process of Deductive
Reasoning. As we have seen elsewhere, the two processes,
Inductive and Deductive Reasoning, respectively are interdependent
—resting upon one another.
Jevons says of Inductive Reasoning: "In Deductive Reasoning we
inquire how we may gather the truth contained in some propositions
called Premises, and put into another proposition called the
Conclusion. We have not yet undertaken to find out how we can
learn what propositions really are true, but only what propositions
are true when other ones are true. All the acts of reasoning yet
considered would be called deductive because we deduce, or lead
down the truth from premises to conclusion. It is an exceedingly
important thing to understand deductive inference correctly, but it
might seem to be still more important to understand inductive
inference, by which we gather the truth of general propositions from
facts observed as happening in the world around us." Halleck says:
"Man has to find out through his own experience, or that of others,
the major premises from which he argues or draws his conclusions.
By induction we examine what seems to us a sufficient number of
individual cases. We then conclude that the rest of these cases,
which we have not examined, will obey the same general law....
Only after general laws have been laid down, after objects have
been classified, after major premises have been formed, can
deduction be employed."
Strange as may now appear, it is a fact that until a comparatively
recent period in the history of man, it was held by philosophers that
the only way to arrive at all knowledge was by means of Deductive
Reasoning, by the use of the Syllogism. The influence of Aristotle
was great and men preferred to pursue artificial and complicated
methods of Deductive Reasoning, rather than to reach the truth by
obtaining the facts from Nature herself, at first hand, and then
inferring general principle from the facts so gathered. The rise of
modern scientific methods of reasoning, along the lines of Inductive
Inference, dates from about 1225-1300. Roger Bacon was one of the
first to teach that we must arrive at scientific truth by a process of
observation and experimentation on the natural objects to be found
on all sides. He made many discoveries by following this process. He
was ably seconded by Galileo who lived some three hundred years
later, and who also taught that many great general truths might be
gained by careful observation and intelligent inference. Lord Francis
Bacon, who lived about the same time as Galileo, presented in his
Novum Organum many excellent observations and facts regarding
the process of Inductive Reasoning and scientific thought. As Jevons
says: "Inductive logic inquires by what manner of reasoning we can
gather the laws of nature from the facts and events observed. Such
reasoning is called induction, or inductive inquiry, and, as it has
actually been practiced by all the great discoverers in science, it
consists in four steps."
The Four Steps in Inductive Reasoning, as stated by Jevons, are
as follows:
First Step.—Preliminary observation.
Second Step.—The making of hypotheses.
Third Step.—Deductive reasoning.
Fourth Step.—Verification.
It will be seen that the process of Inductive Reasoning is
essentially a synthetic process, because it operates in the direction
of combining and uniting particular facts or truths into general truths
or laws which comprehend, embrace and include them all. As Brooks
says: "The particular facts are united by the mind into the general
law; the general law embraces the particular facts and binds them
together into a unity of principle and thought. Induction is thus a
process of thought from the parts to the whole—a synthetic
process." It will also be seen that the process of Inductive Reasoning
is essentially an ascending process, because it ascends from
particular facts to general laws; particular truths to universal truths;
from the lower to the higher, the narrower to the broader, the
smaller to the greater.
Brooks says of Inductive Reasoning: "The relation of induction to
deduction will be clearly seen. Induction and Deduction are the
converse, the opposites of each other. Deduction derives a particular
truth from a general truth; Induction derives a general truth from
particular truths. This antithesis appears in every particular.
Deduction goes from generals to particulars; Induction goes from
particulars to generals. Deduction is an analytic process; Induction is
a synthetic process. Deduction is a descending process—it goes from
the higher truth to the lower truth; Induction is an ascending
process—it goes from the lower truth to the higher. They differ also
in that Deduction may be applied to necessary truths, while
Induction is mainly restricted to contingent truths." Hyslop says:
"There have been several ways of defining this process. It has been
usual to contrast it with Deduction. Now, deduction is often said to
be reasoning from general to particular truths, from the containing
to the contained truth, or from cause to effect. Induction, therefore,
by contrast is defined as reasoning from the particular to the
general, from the contained to the containing, or from effect to
cause. Sometimes induction is said to be reasoning from the known
to the unknown. This would make deduction, by contrast, reasoning
from the unknown to the known, which is absurd. The former ways
of representing it are much the better. But there is still a better way
of comparing them. Deduction is reasoning in which the conclusion
is contained in the premises. This is a ground for its certitude and
we commit a fallacy whenever we go beyond the premises as shown
by the laws of the distribution of terms. In contrast with this, then,
we may call inductive reasoning the process by which we go beyond
the premises in the conclusion.... The process here is to start from
given facts and to infer some other probable facts more general or
connected with them. In this we see the process of going beyond
the premises. There are, of course, certain conditions which regulate
the legitimacy of the procedure, just as there are conditions
determining deduction. They are that the conclusion shall represent
the same general kind as the premises, with a possibility of
accidental differences. But it goes beyond the premises in so far as
known facts are concerned."
The following example may give you a clearer idea of the
processes of Inductive Reasoning:
First Step. Preliminary Observation. Example: We notice that all
the particular magnets which have come under our observation
attract iron. Our mental record of the phenomena may be stated as:
"A, B, C, D, E, F, G, etc., and also X, Y, and Z, all of which are
magnets, in all observed instances, and at all observed times, attract
iron."
Second Step. The Making of Hypotheses. Example: Upon the basis
of the observations and experiments, as above stated, and applying
the axiom of Inductive Reasoning, that: "What is true of the many, is
true of the whole," we feel justified in forming a hypothesis or
inference of a general law or truth, applying the facts of the
particulars to the general, whole or universal, thus: "All magnets
attract iron."
Third Step. Deductive Reasoning. Example: Picking up a magnet
regarding which we have had no experience and upon which we
have made no experiments, we reason by the syllogism, as follows:
(1) All magnets attract iron; (2) This thing is a magnet; therefore (3)
This thing will attract iron. In this we apply the axiom of Deductive
Reasoning: "Whatever is true of the whole is true of the parts."
Fourth Step. Verification. Example: We then proceed to test the
hypothesis upon the particular magnet, so as to ascertain whether or
not it agrees with the particular facts. If the magnet does not attract
iron we know that either our hypothesis is wrong and that some
magnets do not attract iron; or else that our judgment regarding
that particular "thing" being a magnet is at fault and that it is not a
magnet. In either case, further examination, observation and
experiment is necessary. In case the particular magnet does attract
iron, we feel that we have verified our hypothesis and our judgment.
CHAPTER XII.
REASONING BY INDUCTION
The term "Induction," in its logical usage, is defined as follows: "
(a) The process of investigating and collecting facts; and (b) the
deducing of an inference from these facts; also (c) sometimes
loosely used in the sense of an inference from observed facts." Mill
says: "Induction, then, is that operation of the mind, by which we
infer that what we know to be true in a particular case or cases, will
be true in all cases which resemble the former in certain assignable
respects. In other words, Induction is the process by which we
conclude that what is true of certain individuals of a class, is true of
the whole class, or that what is true at certain times will be true in
similar circumstances at all times."
The Basis of Induction is the axiom that: "What is true of the
many is true of the whole." Esser, a well known authority, states this
axiom in rather more complicated form, as follows: "That which
belongs or does not belong to many things of the same kind,
belongs or does not belong to all things of the same kind."
This basic axiom of Induction rests upon the conviction that
Nature's laws and manifestations are regular, orderly and uniform. If
we assume that Nature does not manifest these qualities, then the
axiom must fall, and all inductive reason must be fallacious. As
Brooks well says: "Induction has been compared to a ladder upon
which we ascend from facts to laws. This ladder cannot stand unless
it has something to rest upon; and this something is our faith in the
constancy of Nature's laws." Some authorities have held that this
perception of the uniformity of Nature's laws is in the nature of an
intuitive truth, or an inherent law of our intelligence. Others hold
that it is in itself an inductive truth, arrived at by experience and
observation at a very early age. We are held to have noticed the
uniformity in natural phenomena, and almost instinctively infer that
this uniformity is continuous and universal.
The authorities assume the existence of two kinds of Induction,
namely: (1) Perfect Induction; and (2) Imperfect Induction. Other,
but similar, terms are employed by different authorities to designate
these two classes.
Perfect Induction necessitates a knowledge of all the particulars
forming a class; that is, all the individual objects, persons, things or
facts comprising a class must be known and enumerated in this form
of Induction. For instance, if we knew positively all of Brown's
children, and that their names were John, Peter, Mark, Luke, Charles,
William, Mary and Susan, respectively; and that each and every one
of them were freckled and had red hair; then, in that case, instead
of simply generalizing and stating that: "John, Peter, Mark, Luke,
Charles, William, Mary and Susan, who are all of Brown's children,
are freckled and have red hair," we would save words, and state the
inductive conclusion: "All Brown's children are freckled and have red
hair." It will be noticed that in this case we include in the process
only what is stated in the premise itself, and we do not extend our
inductive process beyond the actual data upon which it is based.
This form of Induction is sometimes called "Logical Induction,"
because the inference is a logical necessity, without the possibility of
error or exception. By some authorities it is held not to be Induction
at all, in the strict sense, but little more than a simplified form of
enumeration. In actual practice it is seldom available, for it is almost
impossible for us to know all the particulars in inferring a general law
or truth. In view of this difficulty, we fall back upon the more
practical form of induction known as:
Imperfect Induction, or as it is sometimes called "Practical
Induction," by which is meant the inductive process of reasoning in
which we assume that the particulars or facts actually known to us
correctly represent those which are not actually known, and hence
the whole class to which they belong. In this process it will be seen
that the conclusion extends beyond the data upon which it is based.
In this form of Induction we must actually employ the principle of
the axiom: "What is true of the many is true of the whole"—that is,
must assume it to be a fact, not because we know it by actual
experience, but because we infer it from the axiom which also
agrees with past experience. The conclusion arrived at may not
always be true in its fullest sense, as in the case of the conclusion of
Perfect Induction, but is the result of an inference based upon a
principle which gives us a reasonable right to assume its truth in
absence of better knowledge.
In considering the actual steps in the process of Inductive
Reasoning we can do no better than to follow the classification of
Jevons, mentioned in the preceding chapter, the same being simple
and readily comprehended, and therefore preferable in this case to
the more technical classification favored by some other authorities.
Let us now consider these four steps.
First Step. Preliminary observation. It follows that without the
experience of oneself or of others in the direction of observing and
remembering particular facts, objects, persons and things, we
cannot hope to acquire the preliminary facts for the generalization
and inductive inference necessary in Inductive Reasoning. It is
necessary for us to form a variety of clear Concepts or ideas of facts,
objects, persons and things, before we may hope to generalize from
these particulars. In the chapters of this book devoted to the
consideration of Concepts, we may see the fundamental importance
of the formation and acquirement of correct Concepts. Concepts are
the fundamental material for correct reasoning. In order to produce
a perfect finished product, we must have perfect materials, and a
sufficient quantity of them. The greater the knowledge one
possesses of the facts and objects of the outside world, the better
able is he to reason therefrom. Concepts are the raw material which
must feed the machinery of reasoning, and from which the final
product of perfected thought is produced. As Halleck says: "There
must first be a presentation of materials. Suppose that we wish to
form the concept fruit. We must first perceive the different kinds of
fruit—cherry, pear, quince, plum, currant, apple, fig, orange, etc.
Before we can take the next step, we must be able to form distinct
and accurate images of the various kinds of fruit. If the concept is to
be absolutely accurate, not one kind of fruit must be overlooked.
Practically this is impossible; but many kinds should be examined.
Where perception is inaccurate and stinted, the products of thought
cannot be trustworthy. No building is firm if reared on insecure
foundations."
In the process of Preliminary Observation, we find that there are
two ways of obtaining a knowledge of the facts and things around
us. These two ways are as follows:
I. By Simple Observation, or the perception of the happenings
which are manifested without our interference. In this way we
perceive the motion of the tides; the movement of the planets; the
phenomena of the weather; the passing of animals, etc.
II. By the Observation of Experiment, or the perception of
happenings in which we interfere with things and then observe the
result. An experiment is: "A trial, proof, or test of anything; an act,
operation, or process designed to discover some unknown truth,
principle or effect, or to test some received or reputed truth or
principle." Hobbes says: "To have had many experiments is what we
call experience." Jevons says: "Experimentation is observation with
something more; namely, regulation of the things whose behavior is
to be observed. The advantages of experiment over mere
observation are of two kinds. In the first place, we shall generally
know much more certainly and accurately with what we are dealing,
when we make experiments than when we simply observe natural
events.... It is a further advantage of artificial experiments, that they
enable us to discover entirely new substances and to learn their
properties.... It would be a mistake to suppose that the making of an
experiment is inductive reasoning, and gives us without further
trouble the laws of nature. Experiments only give us the facts upon
which we may afterward reason.... Experiments then merely give
facts, and it is only by careful reasoning that we can learn when the
same facts will be observed again. The general rule is that the same
causes will produce the same effects. Whatever happens in one case
will happen in all like cases, provided that they are really like, and
not merely apparently so.... When we have by repeated experiments
tried the effect which all the surrounding things might have on the
result, we can then reason with much confidence as to similar
results in similar circumstances.... In order that we may, from our
observations and experiments, learn the law of nature and become
able to foresee the future, we must perform the process of
generalization. To generalize is to draw a general law from particular
cases, and to infer that what we see to be true of a few things is
true of the whole genus or class to which these things belong. It
requires much judgment and skill to generalize correctly, because
everything depends upon the number and character of the instances
about which we reason."
Having seen that the first step in Inductive Reasoning is
Preliminary Observation, let us now consider the next steps in which
we may see what we do with the facts and ideas which we have
acquired by this Observation and Experiment.
CHAPTER XIII.
THEORY AND HYPOTHESES
Following Jevons' classification, we find that the Second Step in
Inductive Reasoning is that called "The Making of Hypotheses."
A Hypothesis is: "A supposition, proposition or principle assumed
or taken for granted in order to draw a conclusion or inference in
proof of the point or question; a proposition assumed or taken for
granted, though not proved, for the purpose of deducing proof of a
point in question." It will be seen that a Hypothesis is merely held to
be possibly or probably true, and not certainly true; it is in the
nature of a working assumption, whose truth must be tested by
observed facts. The assumption may apply either to the cause of
things, or to the laws which govern things. Akin to a hypothesis, and
by many people confused in meaning with the latter, is what is called
a Theory.
A Theory is: "A verified hypothesis; a hypothesis which has been
established as, apparently, the true one." An authority says "Theory
is a stronger word than hypothesis. A theory is founded on principles
which have been established on independent evidence. A hypothesis
merely assumes the operation of a cause which would account for
the phenomena, but has not evidence that such cause was actually
at work. Metaphysically, a theory is nothing but a hypothesis
supported by a large amount of probable evidence." Brooks says:
"When a hypothesis is shown to explain all the facts that are known,
these facts being varied and extensive, it is said to be verified, and
becomes a theory. Thus we have the theory of universal gravitation,
the Copernican theory of the solar system, the undulatory theory of
light, etc., all of which were originally mere hypotheses. This is the
manner in which the term is usually employed in the inductive
philosophy; though it must be admitted that it is not always used in
this strict sense. Discarded hypotheses are often referred to as
theories; and that which is actually a theory is sometimes called a
hypothesis."
The steps by which we build up a hypothesis are numerous and
varied. In the first place we may erect a hypothesis by the methods
of what we have described as Perfect Induction, or Logical
Induction. In this case we proceed by simple generalization or
simple enumeration. The example of the freckled, red-haired
children of Brown, mentioned in a previous chapter, explains this
method. It requires the examination and knowledge of every object
or fact of which the statement or hypothesis is made. Hamilton
states that it is the only induction which is absolutely necessitated by
the laws of thought. It does not extend further than the plane of
experience. It is akin to mathematical reasoning.
Far more important is the process by which hypotheses are
erected by means of inferences from Imperfect Induction, by which
we reason from the known to the unknown, transcending
experience, and making true inductive inferences from the axiom of
Inductive Reasoning. This process involves the subject of Causes.
Jevons says: "The cause of an event is that antecedent, or set of
antecedents, from which the event always follows. People often
make much difficulty about understanding what the cause of an
event means, but it really means nothing beyond the things that
must exist before in order that the event shall happen afterward."
Causes are often obscure and difficult to determine. The following
five difficulties are likely to arise: I. The cause may be out of our
experience, and is therefore not to be understood; II. Causes often
act conjointly, so that it is difficult to discover the one predominant
cause by reason of its associated causes; III. Often the presence of
a counteracting, or modifying cause may confuse us; IV. Often a
certain effect may be caused by either of several possible causes; V.
That which appears as a cause of a certain effect may be but a co-
effect of an original cause.
Mill formulated several tests for ascertaining the causal agency in
particular cases, in view of the above-stated difficulties. These tests
are as follows: (1) The Method of Agreement; (2) The Method of
Difference; (3) The Method of Residues; and (4) The Method of
Concomitant Variations. The following definitions of these various
tests are given by Atwater as follows:
Method of Agreement: "If, whenever a given object or agency is
present without counteracting forces, a given effect is produced,
there is a strong evidence that the object or agency is the cause of
the effect."
Method of Difference: "If, when the supposed cause is present the
effect is present, and when the supposed cause is absent the effect
is wanting, there being in neither case any other agents present to
effect the result, we may reasonably infer that the supposed cause is
the real one."
Method of Residue: "When in any phenomena we find a result
remaining after the effects of all known causes are estimated, we
may attribute it to a residual agent not yet reckoned."
Method of Concomitant Variations: "When a variation in a given
antecedent is accompanied by a variation of a given consequent,
they are in some manner related as cause and effect."
Atwater adds: "Whenever either of these criteria is found free
from conflicting evidence, and especially when several of them
concur, the evidence is clear that the cases observed are fair
representatives of the whole class, and warrant a valid inductive
conclusion."
Jevons gives us the following valuable rules:
I. "Whenever we can alter the quantity of the things experimented
on, we can apply a rule for discovering which are causes and which
are effects, as follows: We must vary the quantity of one thing,
making it at one time greater and at another time less, and if we
observe any other thing which varies just at the same times, it will in
all probability be an effect."
II. "When things vary regularly and frequently, there is a simple
rule, by following which we can judge whether changes are
connected together as causes and effects, as follows: Those things
which change in exactly equal times are in all likelihood connected
together."
III. "It is very difficult to explain how it is that we can ever reason
from one thing to a class of things by generalization, when we
cannot be sure that the things resemble each other in the important
points.... Upon what grounds do we argue? We have to get a
general law from particular facts. This can only be done by going
through all the steps of inductive reasoning. Having made certain
observations, we must frame hypotheses as to the circumstances, or
laws from which they proceed. Then we must reason deductively;
and after verifying the deductions in as many cases as possible, we
shall know how far we can trust similar deductions concerning future
events.... It is difficult to judge when we may, and when we may
not, safely infer from some things to others in this simple way,
without making a complete theory of the matter. The only rule that
can be given to assist us is that if things resemble each other in a
few properties only, we must observe many instances before
inferring that these properties will always be joined together in other
cases."
CHAPTER XIV.
MAKING AND TESTING HYPOTHESES
The older philosophers and logicians were often at a loss how to
reasonably account for the origin of hypotheses. It will be seen, after
giving the matter a little thought, that the actual formation of the
hypothesis is more than a mere grouping together or synthesis of
facts or ideas—there is another mental process which actually
evolves the hypothesis or theory—which gives a possible reason.
What is this mental process? Let us consider the matter. Brooks well
says: "The hypotheses of science originate in what is called
anticipation. They are not the result of a mere synthesis of facts, for
no combination of facts can give the law or cause. We do not see
the law; we see the facts and the mind thinks the law. By the power
of anticipation, the mind often leaps from a few facts to the cause
which produces them or the law which governs them. Many
hypotheses were but a happy intuition of the mind. They were the
result of what La Place calls 'a great guess,' or what Plato so
beautifully designates as 'a sacred suspicion of truth.' The forming of
hypotheses requires a suggestive mind, a lively fancy, a philosophic
imagination, that catches a glimpse of the idea through the form, or
sees the law standing behind the fact."
The student of The New Psychology sees in the mental operation
of the forming of the hypothesis—"the mind thinking the law"—but
an instance of the operation of the activities of the Subconscious
Mind, or even the Superconscious Mind. (See the volume on the
Subconscious Mind in this series.) Not only does this hypothesis give
the explanation which the old psychology has failed to do, but it
agrees with the ideas of others on the subject as stated in the above
quotation from Brooks; and moreover agrees with many recorded
instances of the formation of great hypotheses. Sir Wm. Hamilton
discovered the very important mathematical law of quaternions while
walking one day in the Dublin Observatory. He had pondered long on
the subject, but without result. But, finally, on that eventful day he
suddenly "felt the galvanic circle of thought" close, and the result
was the realization of the fundamental mathematical relations of the
problem. Berthelot, the founder of Synthetic Chemistry, has testified
that the celebrated experiments which led to his remarkable
discoveries were seldom the result of carefully followed lines of
conscious thought or pure reasoning processes; but, instead, came
to him "of their own accord," so to speak, "as from a clear sky." In
these and many other similar instances, the mental operation was
undoubtedly purely subjective and subconscious. Dr. Hudson has
claimed that the "Subjective Mind" cannot reason inductively, and
that its operations are purely and distinctly deductive, but the
testimony of many eminent scientists, inventors and philosophers is
directly to the contrary.
In this connection the following quotation from Thomson is
interesting: "The system of anatomy which has immortalized the
name of Oken is the consequence of a flash of anticipation which
glanced through his mind when he picked up in a chance walk the
skull of a deer, bleached and disintegrated by the weather, and
exclaimed after a glance, 'It is part of a vertebral column!' When
Newton saw the apple fall, the anticipatory question flashed through
his mind, 'Why do not the heavenly bodies fall like this apple?' In
neither case had accident any important share; Newton and Oken
were prepared by the deepest previous study to seize upon the
unimportant fact offered to them, and to show how important it
might become; and if the apple and the deer-skull had been
wanting, some other falling body, or some other skull, would have
touched the string so ready to vibrate. But in each case there was a
great step of anticipation; Oken thought he saw a type of the whole
skeleton in a single vertebra, while Newton conceived at once that
the whole universe was full of bodies tending to fall.... The discovery
of Goethe, which did for the vegetable kingdom what Oken did for
the animal, that the parts of a plant are to be regarded as
metamorphosed leaves, is an apparent exception to the necessity of
discipline for invention, since it was the discovery of a poet in a
region to which he seemed to have paid no especial or laborious
attention. But Goethe was himself most anxious to rest the basis of
this discovery upon his observation rather than his imagination, and
doubtless with good reason.... As with other great discoveries, hints
had been given already, though not pursued, both of Goethe's and
Oken's principles. Goethe left his to be followed up by others, and
but for his great fame, perhaps his name would never have been
connected with it. Oken had amassed all the materials necessary for
the establishment of his theory; he was able at once to discover and
conquer the new territory."
It must not be supposed, however, that all hypotheses flashing
into the field of consciousness from the Subconsciousness, are
necessarily true or correct. On the contrary many of them are
incorrect, or at least only partially correct. The Subconsciousness is
not infallible or omniscient—it merely produces results according to
the material furnished it. But even these faulty hypotheses are often
of value in the later formation of a correct one. As Whewell says: "To
try wrong guesses is with most persons the only way to hit upon
right ones." Kepler is said to have erected at least twenty
hypotheses regarding the shape of the earth's orbit before he finally
evolved the correct one. As Brooks says: "Even incorrect hypotheses
may be of use in scientific research, since they may lead to more
correct suppositions." The supposition of the circular motions of the
heavenly bodies around the earth as a center, which lead to the
conception of epicycles, etc., and at last to the true theory is an
illustration of this. So the 'theory of phlogiston' in chemistry, made
many facts intelligible, before the true one of 'oxidation' superseded
it. And so, as Thomson says, "with the theory that 'Nature abhors a
vacuum,' which served to bring together so many cognate facts not
previously considered as related. Even an incorrect conception of
this kind has its place in science, so long as it is applicable to the
facts; when facts occur which it cannot explain, we either correct it
or replace it with a new one. The pathway of science, some one
remarks, is strewn with the remains of discarded hypotheses."
Halleck says regarding the danger of hasty inference: "Men must
constantly employ imperfect induction in order to advance; but great
dangers attend inductive inferences made from too narrow
experience. A child has experience with one or two dogs at his
home. Because of their gentleness, he argues that all dogs are
gentle. He does not, perhaps, find out the contrary until he has been
severely bitten. His induction was too hasty. He had not tested a
sufficiently large number of dogs to form such a conclusion. From
one or two experiences with a large crop in a certain latitude, a
farmer may argue that the crop will generally be profitable, whereas
it may not again prove so for years. A man may have trusted a
number of people and found them honest. He concludes that people
as a rule are honest, trusts a certain dishonest man, and is ruined.
The older people grow, the more cautious they generally become in
forming inductive conclusions. Many instances are noted and
compared; but even the wisest sometimes make mistakes. It once
was a generally accepted fact that all swans were white. Nobody had
ever seen a dark swan, and the inference that all swans were white
was regarded as certainly true. Black swans were, however, found in
Australia."
Brooks says regarding the probability of hypotheses: "The
probability of a hypothesis is in proportion to the number of facts
and phenomena it will explain. The larger the number of facts and
phenomena that it will satisfactorily account for, the greater our faith
in the correctness of our supposition.... If there is more than one
hypothesis in respect to the facts under consideration, that one
which accounts for the greatest number of facts is the most
probable.... In order to verify a hypothesis it must be shown that it
will account for all the facts and phenomena. If these facts are
numerous and varied, and the subject is so thoroughly investigated
that it is quite certain that no important class of facts has been
overlooked, the supposition is regarded as true, and the hypothesis
is said to be verified. Thus the hypothesis of the 'daily rotation' of
the earth on its axis to account for the succession of day and night is
accepted as absolutely true. This is the view taken by Dr. Whewell
and many other thinkers in respect to the verification of a
hypothesis. Some writers, however, as Mill and his school, maintain
that in order to verify a hypothesis, we must show not only that it
explains all the facts and phenomena, but that there is no other
possible hypothesis which will account for them.... The former view
of verification is regarded as the correct one. By the latter view, it is
evident that a hypothesis could never be verified."
Jevons says: "In the fourth step (verification), we proceed to
compare these deductions with the facts already collected, or when
necessary and practicable, we make new observations and plan new
experiments, so as to find out whether the hypothesis agrees with
nature. If we meet with several distinct disagreements between our
deductions and our observations, it will become likely that the
hypothesis is wrong, and we must then invent a new one. In order
to produce agreement it will sometimes be enough to change the
hypothesis in a small degree. When we get hold of a hypothesis
which seems to give results agreeing with a few facts, we must not
at once assume that it is certainly correct. We must go on making
other deductions from it under various circumstances, and,
whenever it is possible, we ought to verify these results, that is,
compare them with facts observed through the senses. When a
hypothesis is shown in this way to be true in a great many of its
results, especially when it enables us to predict what we should
never otherwise have believed or discovered, it becomes certain that
the hypothesis itself is a true one.... Sometimes it will happen that
two or even three quite different hypotheses all seem to agree with
certain facts, so that we are puzzled which to select.... When there
are thus two hypotheses, one as good as the other, we need to
discover some fact or thing which will agree with one hypothesis and
not with the other, because this immediately enables us to decide
that the former hypothesis is true and the latter false."
In the above statements regarding the verification of hypotheses
we see references made to the testing of the latter upon the "facts"
of the case. These facts may be either the observed phenomena or
facts apparent to the perception, or else facts obtained by deductive
reasoning. The latter may be said to be facts which are held to be
true if the hypothesis be true. Thus if we erect the hypothesis that
"All men are mortal," we may reason deductively that it will follow
that each and every thing that is a man must die sooner or later.
Then we test our hypotheses upon each and every man whom we
may subject to observation and experiment. If we find a single man
who does not die, then the test disproves our hypotheses; if on the
contrary all men (the "facts" in the case) prove to be mortal, then is
our hypotheses proven or established. The deductive reasoning in
this case is as follows: "If so-and-so is true regarding such-and-such
a class; and if this particular thing belongs to that class; then it will
follow that so-and-so is true regarding this particular thing." This
argument is expressed in what is called a Hypothetical Proposition
(see Chapter IX), the consideration of which forms a part of the
general subject of Deductive Reasoning. Therefore as Jevons has
said, "Deductive Reasoning is the Third Step in Inductive Reasoning,
and precedes Verification", which we have already considered.
Halleck says: "After Induction has classified certain phenomena and
thus given us a major premise, we may proceed deductively to apply
the inference to any new specimen that can be shown to belong to
that class. Induction hands over to deduction a ready-made major
premise.... Deduction takes that as a fact, making no inquiry about
its truth.... Only after general laws have been laid down, after
objects have been classified, after major premises have been
formed, can deduction be employed."
In view of the above facts, we shall now proceed to a
consideration of that great class of Reasoning known under the term
—Deductive Reasoning.
CHAPTER XV.
DEDUCTIVE REASONING
We have seen that there are two great classes of reasoning,
known respectively, as (1) Inductive Reasoning, or the discovery of
general truth from particular truths; and (2) Deductive Reasoning, or
the discovery of particular truths from general truths.
As we have said, Deductive Reasoning is the process of
discovering particular truths from a general truth. Thus from the
general truth embodied in the proposition "All horses are animals,"
when it is considered in connection with the secondary proposition
that "Dobbin is a horse," we are able to deduce the particular truth
that: "Dobbin is an animal." Or, in the following case we deduce a
particular truth from a general truth, as follows: "All mushrooms are
good to eat; this fungus is a mushroom; therefore, this fungus is
good to eat." A deductive argument is expressed in a deductive
syllogism.
Jevons says regarding the last stated illustration: "Here are three
sentences which state three different facts; but when we know the
two first facts, we learn or gather the third fact from the other two.
When we thus learn one fact from other facts, we infer or reason,
and we do this in the mind. Reasoning thus enables us to ascertain
the nature of a thing without actual trial. If we always needed to
taste a thing before we could know whether it was good to eat or
not, cases of poisoning would be alarmingly frequent. But the
appearance and peculiarities of a mushroom may be safely learned
by the eye or the nose, and reasoning upon this information and the
fact already well known, that mushrooms are good to eat, we arrive
without any danger or trouble at the conclusion that the particular
fungus before us is good to eat. To reason, then, is to get some
knowledge from other knowledge."
The student will recognize that Deductive Reasoning is essentially
an analytic process, because it operates in the direction of analyzing
a universal or general truth into its particulars—into the particular
parts which are included within it—and asserting of them that "what
is true of the general is true of the particular." Thus in the general
truth that "All men are mortal," we see included the particular truth
that "John Smith is mortal"—John Smith having been discovered to
be a man. We deduce the particular truth about John Smith from the
general truth about "all men." We analyze "all men" and find John
Smith to be one of its particular parts. Therefore, "Deduction is an
inference from the whole to its parts; that is, an analytic process."
The student will also recognize that Deductive Reasoning is
essentially a descending process, because it operates in the direction
of a descent from the universal to the particular; from the higher to
the lower; from the broader to the narrower. As Brooks says:
"Deduction descends from higher truths to lower truths, from laws to
facts, from causes to phenomena, etc. Given the law, we can by
deduction descend to the facts that fall under the law, even if we
have never before seen the facts; and so from the cause we may
pass down to observed and even unknown phenomena."
The general truths which are used as the basis of Deductive
Reasoning are discovered in several ways. The majority arise from
Inductive Reasoning, based upon experience, observation and
experiment. For instance in the examples given above, we could not
truthfully assert our belief that: "All horses are animals" unless we
had previously studied both the horse and animals in general. Nor
without this study could we state that "Dobbin is a horse." Nor could
we, without previous study, experience and experiment truthfully
assert that: "All mushrooms are good to eat;" or that "this fungus is
a mushroom;" and that "therefore, this fungus is good to eat." Even
as it is, we must be sure that the fungus really is a mushroom, else
we run a risk of poisoning ourselves. General truths of this kind are
not intuitive, by any means, but are based upon our own experience
or the experience of others.
There is a class of general truths which are called intuitive by
some authorities. Halleck says of these: "Some psychologists claim
that we have knowledge obtained neither through induction nor
deduction; that we recognize certain truths the moment we perceive
certain objects, without any process of inference. Under the head of
intuitive knowledge are classified such cases as the following: We
perceive an object and immediately know that it is a time relation, as
existing now and then. We are said to have an intuitive concept of
time. When we are told that the whole is greater than a part; that
things equal to the same thing are equal to each other; that a
straight line cannot enclose space, we immediately, or intuitively,
recognize the truth of these statements. Attempts at proof do not
make us feel surer of their truth.... We say that it is self-evident, or
that we know the fact intuitively. The axioms of mathematics and
logic are said to be intuitive."
Another class of authorities, however, deny the nature of intuitive
knowledge of truth, or intuitive truths. They claim that all our ideas
arise from sensation and reflection, and that what we call "intuition"
is merely the result of sensation and reflection reproduced by
memory or heredity. They hold that the intuitions of animals and
men are simply the representation of experiences of the race, or
individual, arising from the impressions stored away in the
subconsciousness of the individual. Halleck states regarding this:
"This school likens intuition to instinct. It grants that the young duck
knows water instinctively, plunges into it, and swims without
learning. These psychologists believe that there was a time when
this was not the case with the progenitors of the duck. They had to
gain this knowledge slowly through experience. Those that learned
the proper aquatic lesson survived and transmitted this knowledge
through a modified structure, to their progeny. Those that failed in
the lesson perished in the struggle for existence.... This school
claims that the intuition of cause and effect arose in the same way.
Generations of human beings have seen the cause invariably joined
to the effect; hence, through inseparable association came the
recognition of their necessary sequence. The tendency to regard all
phenomena in these relations was with steadily increasing force
transmitted by the laws of heredity to posterity, until the recognition
of the relationship has become an intuition."
Another class of general truths is merely hypothetical.
Hypothetical means "Founded on or including a hypothesis or
supposition; assumed or taken for granted, though not proved, for
the purpose of deducing proofs of a point in question." The
hypotheses and theories of physical science are used as general
truths for deductive reasoning. Hypothetical general truths are in the
nature of premises assumed in order to proceed with the process of
Deductive Reasoning, and without which such reasoning would be
impossible. They are, however, as a rule not mere assumptions, but
are rather in the nature of assumptions rendered plausible by
experience, experiment and Inductive Reasoning. The Law of
Gravitation may be considered hypothetical, and yet it is the result of
Inductive Reasoning based upon a vast multitude of facts and
phenomena.
The Primary Basis of Deductive Reasoning may be said to rest
upon the logical axiom, which has come down to us from the
ancients, and which is stated as follows: "Whatever is true of the
whole is true of its parts." Or, as later authorities have expressed it:
"Whatever is true of the general is true of the particular." This axiom
is the basis upon which we build our Deductive Reasoning. It
furnishes us with the validity of the deductive inference or argument.
If we are challenged for proof of the statement that "This fungus is
good to eat," we are able to answer that we are justified in making
the statement by the self-evident proposition, or axiom, that
"Whatever is true of the general is true of the particular." If the
general "mushroom" is good to eat, then the particular, "this fungus"
being a mushroom, must also be good to eat. All horses (general)
being animals, then according to the axiom, Dobbin (particular
horse) must also be an animal.
This axiom has been stated in various terms other than those
stated above. For instance: "Whatever may be affirmed or denied of
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like