Αν η Επιστήμη Υπολογιστών είναι κτίριο, η Λογική είναι το σιδήρο, το σκυρόδεμα, τα σχέδια, και ο νόμος 자연 που το κρατάει όρθιο. Από τα transistors στο silicon μέχρι τα AI models που γράφουν κώδικα, η λογική είναι η ομοιομορφία που τα συνδέει όλα. Δεν είναι "ένα μάθημα" – είναι η γλώσσα της σκέψης στον υπολογισμό.
1. Το Υλικό: Boolean Algebra & Digital Logic
Κάθε bit, κάθε gate, κάθε ALU operation είναι Boolean logic:
- AND, OR, NOT, XOR, NAND, NOR – τα ατομικά σύστατα.
- Combinational circuits: Adders, multipliers, ALUs, encoders/decoders, multiplexers.
- Sequential circuits: Flip-flops, registers, counters, state machines, caches, pipeline registers.
- ISA level: Η machine code είναι λογικές εντολές που χειρίζονται bits σύμφωνα με κανόνες.
Η formal verification υλικού (model checking, theorem proving – π.χ. seL4 kernel, Intel/AMD CPU verification) χρησιμοποιεί λογική για να αποδείξει ορθότηταजहاں το testing δεν φτάνει.
2. Το Λογισμικό: Programming Languages & Correctness
Control Flow & Type Systems
- Conditionals, loops, pattern matching – όλοι βασίζονται σε propositional logic (true/false evaluation).
- Type systems = Logic (Curry-Howard correspondence): Types είναι propositions, programs είναι proofs. Ένα well-typed program είναι ένα proof που το πρόγραμμα ικανοποιεί τις προδιαγραφές του type system.
- Dependent types (Idris, Agda, Coq, Lean): Types που εξαρτώνται από values – επιτρέπουν encoding arbitrary invariants στο type system.
Formal Methods
- Model Checking (SPIN, TLA+, Alloy): Εξερευνούν state space για να αποδειχθούν safety/liveness properties.
- Theorem Proving (Coq, Isabelle/HOL, Lean, F*): Γράφετε specifications και proofs σε λογική υψηλής τάξης. Χρησιμοποιούνται σε CompCert (verified C compiler), seL4, AWS s2n TLS, RustBelt.
- Static Analysis (Abstract Interpretation): Sound over-approximation του program behavior για εύρεση bugs (Astrée για Airbus flight control).
Databases: Relational Algebra & Logic
- SQL = Relational Algebra = First-Order Logic (Codd's theorem). Το SELECT-FROM-WHERE είναι logical query.
- Constraints (PK, FK, CHECK, ASSERTION) είναι logical formulas που πρέπει να ικανοποιούνται.
- Datalog / Recursive CTEs – fixed-point logic για graph queries, program analysis.
3. Τεχνητή Νοημοσύνη: Knowledge Representation & Reasoning
Symbolic AI (GOFAI)
- Propositional & First-Order Logic: Knowledge bases, resolution, unification.
- Description Logics (OWL, SHOIN): Ontologies, semantic web, reasoning over taxonomies.
- Logic Programming (Prolog, Datalog): Programs ως Horn clauses. Backward chaining (SLD resolution).
- Answer Set Programming (ASP): Non-monotonic reasoning για combinatorial problems.
Neuro-symbolic AI
Η σύγχρονη τάση: συνδυασμός neural networks (perception, pattern recognition) με symbolic reasoning (logic, planning, verification). Π.χ. Neural Theorem Provers, Differentiable Logic, Logic-guided ML.
4. Ασφάλεια: Logic as Defense
- Cryptography: Protocol verification με logic (BAN logic, computational logic). Formal proofs για TLS 1.3, Signal protocol, WireGuard.
- Access Control: ABAC, RBAC, ReBAC – policies expressed σε logic (XACML, ALFA, Cedar, OPA/Rego).
- Information Flow Control: Non-interference properties αποδεικνύονται με logical relations.
5. Θεωρητική Επιστήμη Υπολογιστών: Λογική ως Foundation
- Computability: Turing machines, λ-calculus, recursive functions – όλα definable σε λογική.
- Complexity: Descriptive complexity (Fagin's theorem: NP = existential second-order logic).
- Programming Language Semantics: Operational, denotational, axiomatic (Hoare logic) – λογικά frameworks για reasoning προγραμμάτων.
- Concurrency: Temporal logic (LTL, CTL, μ-calculus) για model checking concurrent systems.
Συμπέρασμα: Η Λογική είναι Unavoidable
Δεν μπορείτε να "αποφύγετε" τη λογική στην πληροφορική. Μπορείτε να την αγνοείτε (και να γράφετε buggy, insecure, unmaintainable κώδικα), αλλά το σύστημα που τρέχετε, η γλώσσα που χρησιμοποιείτε, το protocol που επικοινωνείτε, το hardware που εκτελεί – όλα τη τηρούν. Η εξοικείωση με τη λογική (propositional, first-order, higher-order, temporal, modal, linear, separation logic) δεν είναι academic luxury. Είναι το toolkit που σας επιτρέπει να χτίζετε συστήματα που δουλεύουν σωστά, ασφαλώς, και προβλέψιμα. Όπως έλεγε ο Dijkstra: "Program testing can be used to show the presence of bugs, but never to show their absence." Μόνο η λογική μπορεί να δείξει απουσία bugs.