CDP 145 logical programming

Опубликовано: 10 Август 2023
на канале: Complete Developer Network
7
0

In philosophy formal logic is the study of deduction and inference, or the steps in reasoning, through formal content. Logic programming is a paradigm that is based on formal logic. Also known as mathematical logic, formal logic is a sub-field of mathematics. It is basically the application of philosophical logic to mathematics.

Logic is it's own language with syntax, semantics, and inference rules. Syntax are the rules around how to build formulas, or in philosophy the sentences that create the logic statement. This would be the language and what functions and methods are available. Semantics define the meaning of the formulas, or what is created with the syntax, through logical consequences. This would be the outputs of those functions Inference rules are rules setting how to come to conclusions. Rules governing what you can do and expect from functions and methods.

Logical programming is a set of logical deductions that are controlled through a flow. The logic or what is being done is separated from the control or how it is being done. This allows for interchangeable parts where the logic piece sets the result and the the control piece can be changed to still produce the same result.

"Algorithm = Logic + Control" ~ Robert Kowalski

It's basis in mathematics can help us to better understand the underlying functionality of code we are writing. Also reviewing common concepts like control flow in terms of something new helps even the most senior developers better appreciate and understand what they are writing.