Chapter 8 of 13
Ethical Frameworks for AI Decisions: Consequences, Duties, and Virtues in Code
Should an autonomous vehicle be programmed as a utilitarian, a Kantian, or something else entirely? This module applies major ethical theories to AI decision-making, revealing how different moral frameworks lead to different design choices and trade‑offs.
1. Why Ethics Matters in AI Decisions
From Thought Experiments to Code
An autonomous vehicle with brake failure may have to choose between risking passengers or pedestrians. The key question is not only what it should do, but how we should program it to decide in the first place.
Three Big Ethical Families
We will connect three major ethical approaches to AI: utilitarianism (outcomes), deontology (rules and rights), and virtue ethics (character and judgment). Each leads to different design choices in AI systems.
Ethics Hidden in Design
Modern AI systems embed ethics in optimization goals, safety constraints, and override mechanisms. Even when no one says "we use Kant" or "we use utilitarianism", design choices still reflect these theories.
Not Moral Agents, But Moral Tools
We will treat AI systems as tools, not independent moral agents. The core question is how human designers should apply moral theories when building systems that act on our behalf.
2. Utilitarianism: Outcomes and Cost–Benefit in AI
Utilitarianism in One Line
Utilitarianism says the right action is the one that maximizes overall well-being or minimizes total harm. It evaluates actions purely by their consequences, not by rules or motives.
Utilitarian AI = Optimization
An AI system can implement utilitarianism by defining a utility function and always choosing the action with the highest expected utility. This fits naturally with reinforcement learning and decision theory.
Autonomous Vehicle Example
In a crash scenario, a utilitarian AV would estimate harms for each option, including probabilities, and choose the path with the lowest expected total harm, no matter who exactly is harmed.
Worries About Pure Utilitarian AI
Purely utilitarian AI may allow sacrificing one to save many, or ignore rights and fairness. It also depends on controversial choices about how to measure and compare well-being and harms.
3. Coding a Simple Utilitarian Decision Rule
This simplified Python example shows how a utilitarian-style decision can be expressed in code for an autonomous vehicle.
It is not realistic engineering, but it highlights how ethical assumptions become numeric parameters.
```python
from dataclasses import dataclass
from typing import List
@dataclass
class Outcome:
description: str
expected number of people harmed
people_harmed: int
average severity on a 0-10 scale
avg_severity: float
probability this outcome occurs if we choose this action
probability: float
def expected_harm(self) -> float:
simple utilitarian cost: expected total harm
return self.peopleharmed * self.avgseverity * self.probability
def chooseminharm(outcomes: List[Outcome]) -> Outcome:
"""Return the outcome with the lowest expected harm."""
return min(outcomes, key=lambda o: o.expected_harm())
Example: two possible maneuvers in a crash scenario
stay_course = Outcome(
description="Stay on course, risk 2 pedestrians",
people_harmed=2,
avg_severity=7.0,
probability=0.6
)
swerve = Outcome(
description="Swerve, risk 1 passenger",
people_harmed=1,
avg_severity=9.0,
probability=0.4
)
best = chooseminharm([stay_course, swerve])
print("Chosen action:", best.description)
print("Expected harm:", best.expected_harm())
```
Reflect while reading the code:
- Where are the ethical assumptions?
- Treating all persons as equal numbers.
- Compressing complex injuries into a single 0-10 scale.
- Focusing only on physical harm, not rights or justice.
- How could changing the `expected_harm` formula change the moral behavior of the system?
4. Deontology: Duties, Rules, and Rights in AI
What Is Deontology?
Deontological ethics focuses on duties, rules, and rights rather than outcomes alone. Kantian ethics is a key version: treat persons as ends in themselves and act only on principles that could be universal laws.
Deontology in AI Design
In AI, deontology appears as hard constraints: some actions are forbidden, regardless of their benefits. People have rights, such as not being intentionally killed or unfairly discriminated against by an algorithm.
AV and Medical Examples
An AV might be programmed never to intentionally target a specific person. Medical AI may follow triage rules that forbid sacrificing one healthy patient to harvest organs for several others, even if that saves more lives.
From Ethics to Regulation
Deontological ideas show up in safety standards and laws, like the EU AI Act, which bans certain manipulative or discriminatory AI uses. Engineers often optimize only within the space of duty-respecting actions.
5. Adding Deontological Constraints to the Decision Rule
We now extend the earlier code so the AV refuses options that violate a deontological constraint, even if they have lower expected harm.
```python
from dataclasses import dataclass
from typing import List, Callable
@dataclass
class Outcome:
description: str
people_harmed: int
avg_severity: float
probability: float
simple flag: does this action intentionally target a specific person?
targetsspecificperson: bool = False
def expected_harm(self) -> float:
return self.peopleharmed * self.avgseverity * self.probability
def respectsdeontologicalduties(o: Outcome) -> bool:
"""Very simplified deontological filter."""
Example duty: never intentionally target a specific individual
if o.targetsspecificperson:
return False
return True
def chooseactionwith_duties(outcomes: List[Outcome],
duty_check: Callable[[Outcome], bool]) -> Outcome:
1. Filter by duties
allowed = [o for o in outcomes if duty_check(o)]
if not allowed:
raise ValueError("No action respects the duties. Need a fallback policy.")
2. Among allowed actions, minimize expected harm
return min(allowed, key=lambda o: o.expected_harm())
Example outcomes
option_a = Outcome(
description="Swerve toward one identified pedestrian to avoid many",
people_harmed=1,
avg_severity=9.0,
probability=0.9,
targetsspecificperson=True # violates duty
)
option_b = Outcome(
description="Brake and hold course with uncertain outcome",
people_harmed=3,
avg_severity=5.0,
probability=0.5,
targetsspecificperson=False
)
best = chooseactionwithduties([optiona, optionb], respectsdeontological_duties)
print("Chosen action:", best.description)
print("Expected harm:", best.expected_harm())
```
Notice:
- `option_a` has lower expected harm than some alternatives but is rejected because it violates a duty.
- This structure (constraints first, optimization second) mirrors many real-world AI design patterns and safety standards.
6. Virtue Ethics: Character and Practical Wisdom in AI Design
Virtue Ethics in a Nutshell
Virtue ethics focuses on character and practical wisdom. Instead of asking only "What rule?" or "What outcome?", it asks what a good, wise, and just person would do in a concrete situation.
Virtues as Design Principles
We cannot literally give AI a moral character, but we can design systems that embody virtues in their behavior: caution, honesty, fairness, compassion, and respect for vulnerable users.
Examples of Virtuous Design
A medical AI that is transparent and humble about uncertainty, or an AV that drives defensively and yields to pedestrians, are examples of virtue-inspired design choices in real systems.
Shaping Habits and Society
Virtue ethics asks what kinds of habits, attitudes, and social norms AI systems create. Do they support responsible, reflective users and organizations, or do they encourage recklessness and manipulation?
7. Thought Exercise: Triage AI Under Three Frameworks
Imagine a hospital uses an AI system during a pandemic to prioritize patients for intensive care when beds are scarce.
The AI has to rank three patients for the last available ICU bed:
- Patient A: 30 years old, high chance of full recovery.
- Patient B: 70 years old, moderate chance of partial recovery.
- Patient C: 40 years old, low chance of recovery but is the main carer for two children.
Take a minute and mentally sketch how each framework might guide the design.
Task 1: Utilitarian design
- What might the system try to maximize? (e.g., total life-years, quality-adjusted life years, probability of survival?)
- Which patient is likely to be prioritized, and why?
Task 2: Deontological design
- What rules or rights should constrain the system? Examples:
- No discrimination based on age alone.
- Equal respect: use a lottery among patients with similar medical need.
- How might these constraints change the ranking?
Task 3: Virtue-ethical design
- What would a wise and compassionate clinician consider here?
- How could the AI support that judgment instead of replacing it? For example:
- Presenting information clearly.
- Flagging ethical dilemmas.
- Avoiding overconfident recommendations.
Write down (for yourself):
- One sentence describing how each framework would shape the system.
- One limitation of relying only on that framework in this case.
This exercise mirrors real debates in medical ethics and current guidance on clinical decision support systems.
8. Quick Check: Mixing Optimization and Constraints
Test your understanding of how utilitarian and deontological ideas combine in AI design.
An autonomous vehicle system first filters out any action that violates a 'do not intentionally target a person' rule, then among the remaining actions chooses the one with the lowest expected total harm. Which description fits this design best?
- Pure utilitarianism: only outcomes matter, no side constraints.
- Pure deontology: only rules matter, outcomes are ignored.
- A hybrid: deontological constraints first, then utilitarian optimization within the allowed options.
Show Answer
Answer: C) A hybrid: deontological constraints first, then utilitarian optimization within the allowed options.
The system uses a deontological rule as a hard filter (no intentional targeting), then applies a utilitarian calculation (minimize expected harm) over the remaining actions. That is a hybrid design, not a pure version of either theory.
9. Flashcards: Key Terms and Concepts
Use these cards to review the main ethical frameworks and how they map into AI design.
- Utilitarianism
- An ethical theory that judges actions by their consequences, aiming to maximize overall well-being or minimize total harm. In AI, it maps naturally to defining and maximizing a utility function.
- Deontological ethics
- Duty- and rule-based ethics that emphasize rights and constraints on actions, independent of overall outcomes. In AI, it appears as hard constraints or forbidden actions that optimization cannot override.
- Virtue ethics
- An approach focused on character and virtues, asking what a good and wise person would do. In AI, it inspires design principles and systems that support virtuous human behavior and good judgment.
- Expected harm (in decision models)
- A quantitative estimate of harm that multiplies the number of people affected, severity of harm, and probability of the outcome. Often used in utilitarian cost–benefit reasoning for AI decisions.
- Hybrid ethical architecture
- A system design that combines frameworks, for example: first enforcing deontological constraints, then optimizing a utilitarian objective within the allowed action space.
- Responsibility gap
- A situation where it is unclear who is morally or legally responsible for an AI system's actions, especially when no human directly controls the final decision. Connects ethics to accountability and governance.
10. Why No Single Theory Is Enough (and What Designers Do Now)
Real Systems Use Hybrids
Deployed AI systems almost never implement a pure ethical theory. Instead, they mix deontological constraints, utilitarian optimization, and virtue-inspired design principles in different layers of the system.
Limits of Single-Theory Designs
Pure utilitarianism may sacrifice rights, pure deontology can be rigid and conflicting, and pure virtue ethics is hard to formalize. Each theory captures something important but is incomplete on its own.
Emerging Best Practices
Current practice stresses pluralism, human oversight for high-stakes decisions, participatory design with affected communities, and ongoing audits for harm and bias throughout the system life cycle.
Your Critical Lens
When you encounter an AI system, ask which ethical assumptions shape its objectives, constraints, and interfaces, and how alternative assumptions might change who benefits and who bears the risks.
Key Terms
- EU AI Act
- A comprehensive European Union regulation on artificial intelligence adopted in 2024, introducing risk-based categories, bans on certain AI practices, and obligations for high-risk systems. It replaces earlier fragmented guidance with a binding regulatory framework that is phasing into force from 2024 onward.
- Expected harm
- A quantitative estimate of harm, typically computed as the product of the number of people affected, the severity of harm, and the probability of the outcome. Often used in cost–benefit analyses for AI decisions.
- Virtue ethics
- An ethical approach centered on character and virtues such as honesty, courage, and compassion, asking what a good and wise person would do. In AI, it informs design principles and how systems shape user behavior.
- Utilitarianism
- An ethical theory that evaluates actions by their consequences, aiming to maximize overall well-being or minimize total harm. In AI, it aligns with defining and maximizing a utility function.
- Hard constraint
- A rule that an AI system is never allowed to violate, even if doing so would improve its objective score. Often derived from rights-based or deontological considerations.
- Utility function
- A mathematical function that assigns a numerical score (utility) to outcomes so that an AI system can choose actions that maximize expected utility.
- Responsibility gap
- A situation where it is unclear who is morally or legally responsible for the actions or outcomes of an AI system, especially when no human directly controls the final decision.
- Deontological ethics
- A family of ethical theories that focus on duties, rules, and rights, holding that some actions are wrong regardless of their consequences. In AI, this appears as hard constraints or forbidden actions.
- Hybrid ethical architecture
- An AI system design that combines multiple ethical frameworks, for example by applying deontological constraints first and then using utilitarian optimization within the permitted action space.
- Practical wisdom (phronesis)
- In virtue ethics, the capacity to make good judgments in complex, context-dependent situations. For AI, it is approximated through designs that support human judgment rather than replacing it.